【发布时间】:2014-11-25 23:26:00
【问题描述】:
我有page1.php这个代码:
<form action="/redirect.php" method="POST" target="_blank">
<input name="destination" type="hidden" value="a"/>
<input type="submit" value="Click here"></form>
这是redirect.php:
<?php
$url = "http://www.default.com";
if(isset($_POST['destination'])){
switch ($_POST['destination']) {
case "a":
$url = "http://www.domain1.com";
break;
case "b":
$url = "http://www.domain2.com";
break;
default:
$url = "http://www.default.com";
}
}
header( "refresh:1;url=$url" );
?>
<!doctype html>
<html>
<head>
</head>
<body>
<div>Redirecting, Please wait</div>
</body>
</html>
我以这种方式创建了重定向页面,因为对我来说重要的是它会加载并显示某些内容,而不是立即重定向(因此,它会生成 200 代码,而不是 302 代码)。
但是,仅在 Chrome 和 Safari 上,重定向的标头包含有关引用 url 的信息,即 redirect.php,因此,例如,domain1.com 的所有者将知道访问者来自 @987654328 @。
但在 IE 和 FF 上,标头中的引用者为空。是什么导致了这种不同的行为,我该如何解决它以让它们也携带相同的推荐人信息?
【问题讨论】:
-
在这种情况下,我认为autosubmitted forms 将是您的最佳选择。我还没有测试过,但我不是浏览器不发送referer的原因。
-
@machineaddict 您建议将自动提交表单放在哪里?在
redirect.php或page1.php上?我真的不明白这如何解决问题......而且我不希望 URL 地址出现在任何页面的正文中。
标签: php http firefox redirect http-headers