问题
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