开发者

Tracking Incoming Redirects To Your Site

开发者 https://www.devze.com 2023-02-09 20:49 出处:网络
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 redirec

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消