我有一个php文件,将用户重定向到另一个页面,并抓取参考网站。
<?php
$ref = $_SERVER["HTTP_REFERER"];
$url = base64_encode($ref);
header( 'Location: http://link in here.com/?url=' . $url );
?>
这个重定向页面所在的URL需要发布在Facebook上,所以理想情况下需要OG元标签来使它看起来更好(图像,标题文本等)
我不是专家,但我试过把这些标签放在php下面,在php等,但没有乐趣。我想它应该在php中但在header重定向之前?
这是可以做到的吗?如有任何帮助,不胜感激
谢谢
如果你尝试头部刷新会怎么样?
header('Refresh: 0; url=http://link in here.com?url=' . $url);
那么你应该能够设置meta标签。
<?php
$ref = $_SERVER["HTTP_REFERER"];
$url = base64_encode($ref);
header('Refresh: 0; url=http://link in here.com?url=' . $url);
?>
<meta property="og:image" content="http://link in here.com/img.png"/>