Is there a way in which I can find out if a user arrived at my site via a redirect?
Here's an example: There are two sites, first.com & second.com. Any request to first.com will do a 302 redirect to second.com. When the request at second.com arrives, is there anyway to know it was redirected fr开发者_Python百科om first.com?
Note that in this example you have no control over first.com. (In fact, it could be something bad, like kiddieporn.com.)
Also note, because it is a redirect, it will not be in the HTTP referrer header.
if (document.referrer!='')
alert('Welcome visitor, from: '+document.referrer);
Is that what you mean? (Perform your own checks for if "first.com" is within the referrer)
EDIT
However, you're right, most browsers do not send a referrer header with a 302. With that being said, I don't see a way of knowing where they came from. And without control of the redirecting site, it's up to the user to tell you they came from the original source.
精彩评论