【问题标题】:php - how to redirect to be 100% sure that REFERRAL cleaned after redirectphp - 如何重定向到 100% 确保 REFERRAL 在重定向后被清除
【发布时间】:2012-05-24 22:40:21
【问题描述】:

如何重定向用户并确保 HTTP_REFERER 在到达名为 redirect.php 的页面后不会转移到下一页。

程序流程如下:

1) 在http://example.com/index.php 的页面上(包含指向redirect.php 的链接)

2) 用户点击redirect.php的链接,它会发送header('Location: http://otherlocation.com/index.php');

3) 我需要阻止 otherlocation.com 看到来自 http://example.com/index.php 的 HTTP_REFERER

我试过了:

 header('Location:redirect.php');

这不起作用,因为 HTTP_REFERER 填充了第一页 (http://example.com/index.php) 中的值。

【问题讨论】:

  • 问题表述不清楚。你想让我做什么 ?另外,你试过什么??
  • 对不起我的英语,很难描述。我添加了一些详细的说明,逐步说明我的工作和需要。
  • @abrahab,更新了我的答案,查看新代码。
  • @IbrahimAzharArmar 请给我一些时间。您是否 100% 确定 302 重定向将提供 redirect.php 的 HTTP_REFERER,但不会提供 http://domain.com/index.php 的 HTTP_REFERER?
  • @abraab 在这里检查这个链接。 dankind.com/blog/hiding-the-http-referer-with-php-js-or-meta,我试过了,对我来说效果很好。

标签: php redirect


【解决方案1】:

根据浏览器填充 HTTP_REFERER,而不是服务器端

您可以尝试通过

重定向用户
<meta http-equiv="refresh" content="2;url=http://otherlocation.com/index.php" />
<script>document.location = 'http://otherlocation.com/index.php';</script>

浏览器此时未填写 HTTP_REFERER(恕我直言)

在 Firefox 这不起作用:(

【讨论】:

  • 是的,方式,但如果没有启用 javascript 将会失去 thaffic :(
  • 您可以使用 otherlocation.com/index.php"> 发帖
【解决方案2】:

你可以使用

header("Location:redirect.php");

或者如果你想要一些延迟或倒计时,你可以使用。

// 5 is the seconds of the delay to go to the page you've entered.

header("refresh: 5; redirect.php";

【讨论】:

    【解决方案3】:

    要使用 PHP 重定向,请向浏览器发送标头请求。试试这个。

    header('Location:redirect.php',true,302);
    exit;
    

    以上代码会将HTTP_REFERRER 跟踪设置为当前页面。因此从上一页删除跟踪。

    【讨论】:

    • 似乎这种重定向发送链接到redirect.php的页面的http_referral
    猜你喜欢
    • 2021-05-08
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    相关资源
    最近更新 更多