Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my site I have a password protected page containing some links to other sites also operated by myself that cannot be password protected. I would like to place a HTML code onto one of the other sites I operate that checks that the person arriving at the page has been referred from the URL of the 'Links Page'.

(I understand that this is not a secure option)

Summary:

If Referrer = 'Links Page URL' *then* Do nothing *Else* Redirect: www.google.com.

Does anyone know a simple HTML/ Javascript code that I can copy and paste into my site?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
491 views
Welcome To Ask or Share your Answers For Others

1 Answer

if (document.referrer !== "http://www.stackoverflow.com") {
    window.location.href = "http://www.google.com";
}

Or you can use regular expressions to check the referrer.

Anyway, this solution is really, really unsafe. You can just turn off JavaScript in your browser and won't be redirected...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...