HTTP_REFERER coming back with NULL, key does not exist in $_SERVER

我们两清 提交于 2020-01-06 11:46:26

问题


For the first time since using $_SERVER['HTTP_REFERER'] it gives me NULL as a result.

When I do var_dump($_SERVER) the HTTP_REFERER key does not exist.

I also try to visit site with different browsers and from different sites but with no result.

The website is running on a Linux/Apache based server.

How do I fix this?


回答1:


Not all browsers will send the HTTP Referer header - you can't rely on it being sent. For instance, there are plenty of privacy addons which will disable sending of the header, or always send something specific rather than the real referring URL.

A proxy between you and the server could also choose not to pass on this header.

Also, of course, if you've gone straight to the URL in question, there is no referring URL to report.




回答2:


The Referer HTTP header is optional : clients can choose not to send it (or to send a false value).

This means you application can use it -- but must not depend on it.



来源:https://stackoverflow.com/questions/5551094/http-referer-coming-back-with-null-key-does-not-exist-in-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!