[英]Missing HTTP Referrer info on IE/FF (works well on Chrome/Safari)
I have page1.php
with this code: 我有使用此代码的
page1.php
:
<form action="/redirect.php" method="POST" target="_blank">
<input name="destination" type="hidden" value="a"/>
<input type="submit" value="Click here"></form>
and this is redirect.php
: 这是
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>
I've created the redirect page this way because it's important for me that it would load and display certain content, rather than redirect straight away (and thus, it yields out a 200 code, rather than a 302 code). 我以这种方式创建了重定向页面,因为对我来说重要的是它将加载并显示某些内容,而不是立即进行重定向(因此,它产生的是200代码而不是302代码)。
However, only on Chrome and Safari, the Headers of the redirect contain information about the referring url, which is redirect.php
, and thus, for example, the owner of domain1.com
will know that the visitor came from mydomain.com/redirect.php
. 但是,仅在Chrome和Safari上,重定向的标头包含有关引用网址的信息,即
redirect.php
,因此,例如, domain1.com
的所有者将知道访问者来自mydomain.com/redirect.php
。
But on IE and FF, the referrer in the headers is null. 但是在IE和FF上,标头中的引荐来源网址为null。 What is causing this different behavior and how can I fix it to have them carry the same referrer info as well?
是什么导致了这种不同的行为,我如何解决它以使它们也携带相同的引荐来源信息?
您可以尝试:
header("Location: ".$url."");
Working example (tried on FF 27.0.1): 工作示例(在FF 27.0.1上尝试):
File page1.php
: 文件
page1.php
:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Starting page</title>
</head>
<body>
<form action="redirect.php" method="post">
<input type="hidden" name="destination" value="a">
<input type="submit" value="Click here">
</form>
</body>
</html>
File redirect.php
: 文件
redirect.php
:
<?php
$url = "http://www.default.com";
if(isset($_POST['destination'])){
switch ($_POST['destination']) {
case "a":
$url = "http://www.domain.com";
break;
case "b":
$url = "http://www.examples.com";
break;
default:
$url = "http://www.example.com";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Landing page</title>
</head>
<body>
<div>Redirecting, Please wait</div>
<script>
window.onload = function() {
setTimeout(function(){
window.location = '<?php echo $url;?>';
}, 4000);
};
</script>
</body>
</html>
How it's working: After clicking the button Click here
on page1.php
, the post data is sent and the domain http://www.domain.com
is chosen. 如何它的工作:点击按钮后
Click here
上page1.php
,后的数据发送和域http://www.domain.com
选择。 With javascript, after 4 seconds after window onload, the browser will redirect the user to http://www.domain.com
. 使用javascript,在窗口加载后4秒钟后,浏览器会将用户重定向到
http://www.domain.com
。 I have watched the referer headers in Firebug
and they were sent. 我已经看过
Firebug
的引荐来源标头,并且这些标头已发送。
Confused. 困惑。 Redirect and page refresh is not equally.
重定向和页面刷新并不相同。 And more - not all browsers support refresh header.
还有更多-并非所有浏览器都支持刷新标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.