簡體   English   中英

使用javascript重定向基於Blogger博客中的引薦來源域進行重定向

[英]redirect based on referrer domain in blogger blog using javascript redirect

我有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插件這樣的選項。 那么有可能在Blogger博客中實現上述目標嗎? 提前致謝。

這就是在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"); } 
 <div id="ref"></div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM