您的位置:首页 > PHP, 程序相关 > HTTP_REFERER有效和无效的情况

HTTP_REFERER有效和无效的情况

HTTP_REFERER有效和无效的情况

【准备】
test.php文件
echo $_SERVER['HTTP_REFERER'];

【有效的情况】
1、以iframe 形式调用地址,如下所示

2、以window.open调用,打开新页面
window.open(url);

3、使用window.location.replace在Firefox 和Chrome下可以获取HTTP_REFERER

window.location.replace(url);

4、使用window.location.href在Firefox 和Chrome下可以获取HTTP_REFERER
window.location.href = url;

5、使用A标签跳转可以获取HTTP_REFERER

【无效的情况】
1、使用函数 file_get_contents或file等函数调用URL地址,这个地址所在的文件无法获取HTTP_REFERER

2、使用window.location.replace在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.replace(url);

3、使用window.location.href在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.href = url;

本文地址:HTTP_REFERER有效和无效的情况    文章出处:PHP源码阅读,PHP设计模式,PHP学习笔记,项目管理-胖胖的空间

转载请以链接形式注明原始出处和作者,谢绝不尊重版权者抄袭!

2 条留言我要留言

  •   1 - hy0kl  |  2010-05-19 at 6:21 pm  

    Hi,博主的文章写的不错,换个链接吧.
    我也是个 php fans,有机会多交流一下了.呵.
    http://hi.baidu.com/hy0kl

  •   2 - 梦三秋  |  2011-01-05 at 3:31 pm  

    研究的很全呀~~

必填

必填,绝不公开

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word