1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect based on user agent

Discussion in 'HTML & JavaScript' started by DamnedFreak, Sep 5, 2010.

  1. DamnedFreak

    DamnedFreak Junior Member

    Joined:
    Feb 12, 2010
    Messages:
    129
    Likes Received:
    14
    All,

    I would need a script that does a redirect of the visitor to another site, depending on which user agent is provided.

    The background of it is that I want the google bot to see a different site than the one the users sees.

    Regards,
    Steve
     
  2. gimmedat

    gimmedat Junior Member

    Joined:
    Jan 9, 2009
    Messages:
    106
    Likes Received:
    52
    Occupation:
    cartographer
    Location:
    VA
    Code:
    <?php
    
    $agent = $_SERVER['HTTP_USER_AGENT'];
    
    if (eregi("google", $agent))
    {
        Header( "Location: " . "http://cloaked.com" );
    } else {
        Header( "Location: " . "http://acaimonies.com" );
    }
    
    ?>
     
    • Thanks Thanks x 1
  3. tommytx

    tommytx Newbie

    Joined:
    Nov 10, 2005
    Messages:
    11
    Likes Received:
    2
    Be careful with that... google routinely visits the site from another non google to catch cloakers... its an automatic forever ban.... also they routinely request a weird page like htkjajaljkjklfjfjfkjakjklfda.htm to see if you give them a page for that... if its not a 404 error auto ban.... they are doing everything to catch you..
     
    • Thanks Thanks x 1
  4. DamnedFreak

    DamnedFreak Junior Member

    Joined:
    Feb 12, 2010
    Messages:
    129
    Likes Received:
    14
    Thanks to both of you for enlightening me.
    Seems I should read a bit more on cloaking and what Google already does about it.

    My thought was to rank a site based on Wordpress for a keyword, and redirect the traffic directly to a CPA offer once I'm ranking, yet still wanted Google to see and crawl my WP page.

    Cheers,
    Steve