简体   繁体   中英

redirect based on referrer domain in blogger blog using javascript redirect

I have 3 blogger blog with domain looks like

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

If someone clicks any of the links below from a particular site (example, google.com) they should not face any redirect but when they access the link from anywhere in the web they should be redirected to example.com/alllinks . There wont be a single permalink match between 3 blogs.

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

For Example,,, user from anywhere except 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

user referred from 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)

Since the blogs are blogspot blog i dont have access to .htaccess and have no option like wordpress plugins. So is it possible to achieve the above in blogger blog? Thanks in advance.

This is how you get the referrer in Javscript. After that you can redirect your users based on it. (To test it, try copying the link to this answer, go to google and then paste the link you copied in your ADDRESS bar)

 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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM