Redirect based on referrer URL

后端 未结 3 1230
庸人自扰
庸人自扰 2020-12-10 14:04

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

3条回答
  •  孤街浪徒
    2020-12-10 15:02

    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...

提交回复
热议问题