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.

Redirecting googlebot in PHP

Discussion in 'PHP' started by schlottke, Jun 16, 2004.

  1. #1
    If I want to redirect the googlebot for one page which includes ?ref=xxx to another that does not, what would the code look like to do this, without redirecting any visitors.
     
    schlottke, Jun 16, 2004 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Put this on your first line:

    if (preg_match("#(google|slurp@inktomi|yahoo! slurp|msnbot)#si", $_SERVER['HTTP_USER_AGENT'])) {
    
    	header("HTTP/1.1 301 Moved Permanently");
    	header("Location: http://www.new-location.com/");
    	exit;
    }
    PHP:
    That will do it for a few other bots too, not just Google.
     
    digitalpoint, Jun 16, 2004 IP
  3. john_loch

    john_loch Rodent Slayer

    Messages:
    1,294
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    138
    #3
    If you want to redirect googlebot only, ensure you're a little more specific than just a referrer that contains 'google'. Referrers can include mediapartners-googlebot, google-proxy, etc etc.

    :)
     
    john_loch, Jun 17, 2004 IP
  4. schlottke

    schlottke Peon

    Messages:
    2,185
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #4
    schlottke, Jun 17, 2004 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    Yeah, I would put a test for whatever you are looking for as the only thing you redirect.
     
    digitalpoint, Jun 17, 2004 IP
  6. polosas

    polosas Well-Known Member

    Messages:
    289
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    #6
    is there any new ways to redirect google bot ?
     
    polosas, Sep 10, 2009 IP