php - $_SERVER ['HTTP_REFERER'] 丢失

标签 php

我想在我的站点中使用 $_SERVER['HTTP_REFERER'] 但我得到以下信息:

Notice: Undefined index: HTTP_REFERER 

我试过打印 $_SERVER。这将输出以下内容:

Array
(
    [HTTP_HOST] => 192.168.1.10
    [HTTP_USER_AGENT] => Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_CONNECTION] => keep-alive
    [PATH] => /sbin:/usr/sbin:/bin:/usr/bin
    [SERVER_SIGNATURE] => Apache/2.2.3 (CentOS) Server at 192.168.1.10 Port 80
    [SERVER_SOFTWARE] => Apache/2.2.3 (CentOS)
    [SERVER_NAME] => 192.168.1.10
    [SERVER_ADDR] => 192.168.1.10
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 192.168.1.77
    [DOCUMENT_ROOT] => /var/www/html
    [SERVER_ADMIN] => root@localhost
    [SCRIPT_FILENAME] => /var/www/html/sandeep/test/hash.php
    [REMOTE_PORT] => 53851
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /sandeep/test/hash.php
    [SCRIPT_NAME] => /sandeep/test/hash.php
    [PHP_SELF] => /sandeep/test/hash.php
    [REQUEST_TIME] => 1347365919
)

任何人都可以帮我找到 HTTP_REFERER 或建议替代 HTTP_REFERER 吗?

最佳答案

来自文档:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

http://php.net/manual/en/reserved.variables.server.php

关于php - $_SERVER ['HTTP_REFERER'] 丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12369615/

相关文章:

php - cloudflare 的 SSL 错误

php - 使用 .htaccess 设置环境变量

php - 如何在我的 in php 应用程序中修复来自 sqlite 的这些警告?

php - Http 请求在模拟器上失败

PHP/MySQL 根据第二个表中 X 行中的 1 选择一个列表

php - mysql 查询需要在变量周围加上引号

php - 阻止浏览器询问用户是否要刷新页面

javascript - 如何在我的 Javascript 中访问 PHP 数组?

php - 网站登录系统

php - 如果我不选中复选框,则未定义索引