问题
I've been tracking referrers to my site and storing it a session to be used in some reports when they do certain actions.
To get the referrer, I just do $_SESSION["s1"] = $_SERVER["HTTP_REFERER"];
It seems to work for everything except YouTube. Clicking a link on YouTube generates a blank referrer. What could cause this? Does YouTube do something to the headers? Does opening a new window lose the referrer info?
回答1:
I came across this same issue today. Even though this question is 5 years old it came up first on Google when I searched for the cause; so I am going to answer it here for others who stumble across it.
The issue is not so much related to YouTube and is actually caused by the browser. Some browsers will remove the referer header when traffic switches protocols from HTTPS to HTTP. To maintain the referer header you would have to link it to a URI that uses HTTPS as its protocol.
来源:https://stackoverflow.com/questions/10391107/youtube-not-showing-as-a-referrer