在IE / FF上缺少HTTP引用信息(在Chrome / Safari上运行良好) [英] Missing HTTP Referrer info on IE/FF (works well on Chrome/Safari)

查看:165
本文介绍了在IE / FF上缺少HTTP引用信息(在Chrome / Safari上运行良好)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 page1.php 这个代码:

 < ; form action =/ redirect.phpmethod =POSTtarget =_ blank> 
< input name =destinationtype =hiddenvalue =a/>
< input type =submitvalue =Click here>< / form>

这是 redirect.php

 <?php 

$ url =http://www.default.com; ($ _BOST ['destination'])){
$ b $ a:
$ url =http://www.domain1.com;
break;

案例b:
$ url =http://www.domain2.com;
break;

默认值:
$ url =http://www.default.com;



header(refresh:1; url = $ url);

?>
<!doctype html>
< html>
< head>
< / head>
< body>
< div>重新导向,请稍等< / div>
< / body>
< / html>

我以这种方式创建了重定向页面,因为它对于我来说很重要,内容,而不是直接重定向(因此,它产生了一个200代码,而不是一个302代码)。然而,只有在Chrome和Safari,头的重定向包含有关引荐网址的信息,该网址是 redirect.php ,因此,例如, domain1.com 会知道访问者来自 mydomain.com/redirect.php



但是IE和FF,标题中的引用者为空。什么是导致这种不同的行为,我怎样才能解决它,让他们进行相同的引用信息以及? 解决方案

工作示例(试用于FF 27.0.1):
$ b

文件 page1.php

 <!DOCTYPE html> 
< html>
< head>
< meta charset =utf-8>
< title>开始页面< / title>
< / head>
< body>
< form action =redirect.phpmethod =post>
< input type =hiddenname =destinationvalue =a>
< input type =submitvalue =点击这里>
< / form>
< / body>
< / html>

文件 redirect.php

 <?php 

$ url =http://www.default.com; ($ _BOST ['destination'])){
$ b $ a:
$ url =http://www.domain.com;
break;

案例b:
$ url =http://www.examples.com;
break;

默认:
$ url =http://www.example.com;
}
}

?>
<!DOCTYPE html>
< html>
< head>
< meta charset =utf-8>
< title>登陆页面< / title>
< / head>
< body>
< div>重新导向,请稍等< / div>
< script>
window.onload = function(){
setTimeout(function(){
window.location ='<?php echo $ url;?>';
}, 4000);
};
< / script>
< / body>
< / html>

工作原理:点击点击这里 page1.php 上发送发布的数据,域 http://www.domain.com选择。使用javascript,在window onload 4秒后,浏览器将把用户重定向到 http://www.domain.com 。我看过 Firebug 中的引用标题,并且发送了它们。


I have page1.php with this code:

<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:

<?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).

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.

But on IE and FF, the referrer in the headers is null. What is causing this different behavior and how can I fix it to have them carry the same referrer info as well?

解决方案

Working example (tried on FF 27.0.1):

File 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:

<?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. With javascript, after 4 seconds after window onload, the browser will redirect the user to http://www.domain.com. I have watched the referer headers in Firebug and they were sent.

这篇关于在IE / FF上缺少HTTP引用信息(在Chrome / Safari上运行良好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆