Send Google Bot to a Different URL?

agag2

Supreme Member
Joined
Feb 17, 2009
Messages
1,303
Reaction score
250
Hi
I have a website example .com (not real) is it possible to send google to one URL and a (real) user to another..


example .com /URL1
For user it stays on example .com /URL1 but for google bot it redircets to
example .com/bot or some other external URL..

How would I do this?
Thanks
 
Search for "cloaking" which is a general term used for sort of throwing up variations/redirects between search engine spiders/bots and users. There are a crap ton of sample and simple code snippets to use depending on your specific need.
 
Can anyone offer code for this specific task..

One that tricks all google spiders..
 
Code:
<?php
if ( strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot") ) {
    header('Location: http://www.example.com/');
}
?>
 
Last edited:
Code:
<?php
if ( strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot") ) {
    header('Location: http://www.example.com/');
}
?>
Thanks.

Where would I enter URL 1 and the secodn (redirect) URL..


Im intrested in redirecting many different pages on my site to many different urls (external)
 
does this suit your needs?

Code:
<?php

$urls = array(
    "http://url1.com/a.html" => "http://redirecturl1.com",
    "http://url2.com/b.html" => "http://redirecturl2.com",
);

if ( strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot") ) {
    foreach(array_keys($urls) as $url) {
        if ( strstr($url, $_SERVER['REQUEST_URI']) ) {
            header('Location: ' . $urls[$url]);
            return;
        }
    }
}

?>
 
Back
Top