【问题标题】:redirect based on referrer domain in blogger blog using javascript redirect使用 javascript 重定向基于博主博客中的推荐人域进行重定向
【发布时间】:2015-05-07 18:33:48
【问题描述】:

我有 3 个博客,域名看起来像

example1.blogspot.com 
example2.blogspot.com 
example3.blogspot.com

如果有人从特定网站(例如 google.com)点击下面的任何链接,他们不应该面临任何重定向,但是当他们从网络上的任何地方访问链接时,他们应该被重定向到 example.com/alllinks。 3 个博客之间不会有一个永久链接匹配。

example1.blogspot.com 
example2.blogspot.com 
example3.blogspot.com
example1.blogspot.com/alllinks1 
example2.blogspot.com/alllinks2 
example3.blogspot.com/alllinks3

例如,,, 来自 google.com 以外任何地方的用户

example1.blogspot.com to example.com/page1
example2.blogspot.com to example.com/page2
example3.blogspot.com to example.com/page3
example1.blogspot.com/alllinks1 to example.com/alllinks1
example2.blogspot.com/alllinks2 to example.com/alllinks2
example3.blogspot.com/alllinks3 to example.com/alllinks3

从 google.com 推荐的用户

example1.blogspot.com (noredirect)
example2.blogspot.com (noredirect)
example3.blogspot.com (noredirect)
example1.blogspot.com/alllinks1 (noredirect)
example2.blogspot.com/alllinks2 (noredirect)
example3.blogspot.com/alllinks3 (noredirect)

由于博客是 blogspot 博客,我无法访问 .htaccess,也没有像 wordpress 插件这样的选项。那么有没有可能在博主博客中实现以上功能呢?提前致谢。

【问题讨论】:

  • 我从来不用处理 blogspot,但我猜你可以编写服务器端脚本,对吧?
  • 算了。就做var ref=document.referrer
  • @Psoniax 感谢您的回复...你能解释一下我的工作吗.. 我不知道 var ref=document.referrer 是什么意思

标签: javascript redirect dns blogspot


【解决方案1】:

这就是您在 Javscript 中获取引荐来源网址的方式。之后,您可以根据它重定向您的用户。 (要测试它,请尝试复制此答案的链接,转到google,然后将复制的链接粘贴到地址栏中)

var ref=document.referrer;
document.getElementById("ref").innerHTML += ref + "<br />";
if (ref.indexOf("google") > -1)
  {
    document.getElementById("ref").innerHTML += ("You came here from google");
  }
&lt;div id="ref"&gt;&lt;/div&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    相关资源
    最近更新 更多