根据引荐来源网址重定向 [英] Redirect based on referrer URL

查看:125
本文介绍了根据引荐来源网址重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站中,我有一个受密码保护的页面,其中包含一些由我自己管理的网站的链接,这些链接不能用密码保护。我希望将HTML代码放到我操作的其他网站之一上,以检查到达该网页的用户是否已从'链接页面'的网址进行了引用。



(据我所知,这不是一个安全的选择)
$ b strong>

 如果Referrer ='Links Page URL'*则*不做任何操作* Else *重定向:www.google.com。 

有谁知道我可以复制并粘贴到我的网站的简单HTML / Javascript代码?

解决方案

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

或者您可以使用正则表达式来检查引荐来源。



无论如何,这个解决方案真的非常不安全。您可以在浏览器中关闭JavaScript,不会被重定向...


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?

解决方案

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

这篇关于根据引荐来源网址重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆