Redirecting from google search results

Discussion in 'PHP' started by Lindsey2002, Sep 25, 2007.

  1. #1
    I have a question about redirecting the user from google search results to a desired page.

    To make myself clear.
    I have content on several pages that might come up in the search result a user run on google. However, I would like the user to arrive actually at the home page of my website. I am not sure which method to use in order to do so...

    I am familiar with php programming but don't have a really good idea what should be a good way to start build a code that will deal with this.

    I'll appreciate your suggestions to specific methods or previous threads/reading materials dealing with this issue

    thanks
     
    Lindsey2002, Sep 25, 2007 IP
  2. meetgs

    meetgs Active Member

    Messages:
    957
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    70
    #2
    put this on your desired page, before any output is sent:

    if (strpos(strtolower($_SERVER['HTTP_REFERER']),'google.co')) {
    	header('Location: http://www.example.com');
    	exit();
    }
    PHP:
     
    meetgs, Sep 25, 2007 IP
  3. Lindsey2002

    Lindsey2002 Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    does it mean that if googlebot will arrive at this page it will be redirected at a different page?
    I wouldn't want that to happen
     
    Lindsey2002, Sep 30, 2007 IP
  4. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #4
    Since you're familiar with PHP you can understand this page from the PHP.net php manual

    If the "host" parametr contains the string "google", you redirect the user depending on the "query" value or whatever you want...
     
    nabil_kadimi, Sep 30, 2007 IP
  5. meetgs

    meetgs Active Member

    Messages:
    957
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    70
    #5
    of course not, the code checks for the Referer header.
    (whether it contains the string "google.co" in it)

    if googlebot visits your site, the Referer header will not contain google.co (googlebot does not search google, it simply crawls the links)
     
    meetgs, Sep 30, 2007 IP
  6. Lindsey2002

    Lindsey2002 Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks a million
     
    Lindsey2002, Sep 30, 2007 IP
  7. ma0

    ma0 Peon

    Messages:
    218
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You are looking for "trouble".
    You want that your users get redirected to your home page while googlebot just crawl that original page.
    This is black hat SEO, because you want to fool google bot.
    You are risking to lose ranking with this kind of tricks.

    Remember: when you want a bot to see a different page from the page that a normal user is seeing, that is cheating. At least for google. :)

    To do that is very easy. just check the User Agent. When you see googlebot you do nothing; when you see any other agent, just redirect.
    Use at your own risk
     
    ma0, Oct 1, 2007 IP