清除引荐来源网址时重定向。 php 如果可能的话
我有一个 php 脚本,用于检查引荐来源网址在短暂的过程后是否已被清除,如果是,则转发到目的地,如果未清空,则我用于清除引荐来源网址的过程将重新启动。 到目前为止,它有效,这是我使用的代码:
<?php
$referer = $_SERVER['HTTP_REFERER'];
if($referer == "")
{
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://sitetogoto.com\">";
}
else
{
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://sitewherereferrergetsclearedagain.com\">";
}
?>
到目前为止,如果我单击将我带到该脚本的链接,它会将我带到 sitetogoto.com,而无需引用者。 然而,我注意到,例如,在使用自动冲浪时,我陷入了无休止的重定向,其中引荐来源网址不清楚......知道为什么吗?
问候
I have a php script that check if the referrer has been cleared after a short process, if it is it forwards to the destination, if it isn't blanked, the process I used for clearing the referrer restarts. It works so far, this is the code I used:
<?php
$referer = $_SERVER['HTTP_REFERER'];
if($referer == "")
{
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://sitetogoto.com\">";
}
else
{
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://sitewherereferrergetsclearedagain.com\">";
}
?>
This seems to work so far if I click a link that brings me to that script, it brings me to sitetogoto.com without a referrer. However, I have noticed when using an autosurf for example, I get stuck in an endless redirect where the referrer just doesn't clear... Any idea why?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
if(isset($_SESSION['HTTP_REFERER']))
或if(empty($_SESSION['HTTP_REFERER']))
Try
if(isset($_SESSION['HTTP_REFERER']))
orif(empty($_SESSION['HTTP_REFERER']))
在 PHP 中,一种干净的方法是标头重定向
编辑(您的问题)
In PHP a clean way is a header redirection
Edit (Your Question)
当然这是行不通的。 httpreferer是在浏览器、客户端设置的,而不是通过服务器设置的。
尝试使用javascript清除它
Of course this doesn't work. the http referer is set in the browser, client side and not through the server.
Try to clear it using javascript