1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect based on referrer domain in blogger blog using javascript (Important)

Discussion in 'JavaScript' started by dhineshramu, May 7, 2015.

  1. #2
    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.
     
    Last edited by a moderator: May 7, 2015
    dhineshramu, May 7, 2015 IP
  2. billzo

    billzo Well-Known Member

    Messages:
    961
    Likes Received:
    278
    Best Answers:
    15
    Trophy Points:
    113
    #3
    You can use the javascript document.referrer to get the referring URL. You can redirect using window.location. I don't know why this would not work on Blogspot (I have not tested it there).
     
    billzo, May 8, 2015 IP
  3. dhineshramu

    dhineshramu Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #4
    Thanks for the reply... sadly i am not a programmer and i dont know javascript... can you help me with the code i have to use?
     
    dhineshramu, May 8, 2015 IP
  4. billzo

    billzo Well-Known Member

    Messages:
    961
    Likes Received:
    278
    Best Answers:
    15
    Trophy Points:
    113
    #5
    I actually know very little Javascript. This should be a simple pattern match on the referrer URL then a redirect using window.location. I will stop by again tomorrow.

    Maybe somebody else can help here?
     
    billzo, May 8, 2015 IP