Redirect a visitor based on referer, but not Google crawler

3 replies
I have a strong backlink from a site I don't own, to one of my sites (Site A), and for any visitor who clicks through it I'd like to redirect them to another site of mine (Site B). I only want this to happen for people who arrive at Site A via this backlink. I can't get in touch with the owner of the site to ask them to change it. I believe I can do this with a htaccess rule on Site A like this:

RewriteCond %{http_referer} ^http://([^.]+\.)*(linksite)\.com
RewriteRule ^$ http://siteb.com [R=301,L]

HOWEVER, if a google crawler arrives at my site through that link, I do not want to redirect it, as I'm worried I will lose the PR / link juice if I do that (I'd rather keep that on site A).

Can anyone tell me if a) I'm worrying about nothing, and google crawlers will still see that link as going to Site A, or b) I need to put in a "except for Google crawlers* line in my htaccess? Any thoughts how to do that, if so?
#based #crawler #google #redirect #referer #visitor
  • Profile picture of the author mariya20
    use this code :

    RewriteCond %{http_referer} ^http://([^.]+\.)*(Link-Site)\.com
    RewriteRule ^$ special-Page.html [R=302,L]

    In this example, we look for referer’s from Link-Site and we direct them to a page on our site called special-Page.html.

    You should change the domain and the page to anything you like.

    NOTE: You need to have the apache module mod_rewrite installed on your web server.

    Enjoy !
    {{ DiscussionBoard.errors[8031705].message }}
  • Profile picture of the author Night Dreamz
    ooh that's complicated , If you want to redirect all visitors to new site.
    Then save this code in your index file as extension .php.
    e.g
    index.php
    then when ever any one open your sie it will redirected to your given site
    <?php
    header("Location: http://yourdomain.com/");
    exit();
    ?>
    {{ DiscussionBoard.errors[8033215].message }}
  • Profile picture of the author phpg
    Regular google bot does not pass referer, so you shouldn't worry about that.

    On the other hand, they sometimes use other bots (or humans) which do not reveal that they are google, may pass referer, try to read javascript etc., just to catch tricks like that.

    I'd suggest you do actual redirect with javascript, better obfuscated, while still keeping the referer condition.
    {{ DiscussionBoard.errors[8034616].message }}

Trending Topics