无需HTTP_REFERER即可获取引荐页面 [英] Get Referrer Page without HTTP_REFERER

查看:135
本文介绍了无需HTTP_REFERER即可获取引荐页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 $ _ SERVER ['HTTP_REFERER'] 未打开且您无权访问php.ini文件,是否可以获取引用链接页面?

Is it possible to get the referrer page if $_SERVER['HTTP_REFERER'] is not turned on and you dont have access to the php.ini file?

我使用了 print_r($ _ SERVER),并且在回显的数据中没有看到HTTP_REFERER。

I used print_r($_SERVER) and saw nothing about HTTP_REFERER in the echoed data.

以下是我的脚本来获取引荐网站信息,但现在我需要使用JavaScript,但不知道如何使用它:

Below is my script to get the referrer site info but now I need to use JavaScript but am not sure how to work it in:

<? 
    //ini_set("display_errors","2");
    //ERROR_REPORTING(E_ALL);
    $last_page = GetHostByName($_SERVER['HTTP_REFERER']);

    if(strpos($last_page,"fall2011")) {
        echo '<li><a href="'. $last_page  .'" class="navigation-link">Fall 2011</a></li>';
    } else {
        echo $last_page;
    }    
?>


推荐答案

这是不可能的。

最好你可以做的就是投入一些JavaScript。

Best what you could do is to throw in some JavaScript.

var referrer = document.referrer;

如果您在PHP方面需要 那么你需要让JS通过Ajax发送它,或者将它作为表单的隐藏输入字段添加,或者作为查询字符串追加到内部页面链接。困难的部分是将正确的引用链接与服务器端请求的页面相关联。

If you need this in the PHP side (and thus the requirement can't be accomplished by JS alone), then you need to let JS send it by Ajax, or add it as a hidden input field of a form, or append as a query string to internal page links. The hard part is associating the right referrer with the requested page in the server side.

这篇关于无需HTTP_REFERER即可获取引荐页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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