Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess 301 redirect only for google bot

I am essentialy trying to cloak Google certain pages on my site to another. Reason being is i am using this site for paid traffic but i wish to send the SEO traffic elsewhere (via a 301 redirection) as the conversions will be better.

Anyway here is the htaccess i have written so far but i dont know how to add multiple pages.

RewriteEngine On 
RewriteCond %{HTTP_HOST} http://www.currentsite.com/ [NC]
RewriteCond %{HTTP_HOST} http://www.currentsite.com/page1 [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot
RewriteRule ^(.*)$ http://www.newsite.com/ [L,R=301]
RewriteRule ^(.*)$ http://www.newsite.com/page1 [L,R=301]

I assume you can see what i am trying to achieve, redirecting page1 to page1 etc.

Thanks

Morgan

like image 735
Morgan Avatar asked Nov 23 '25 04:11

Morgan


1 Answers

RewriteCond work only with the first RewriteRule just after. You can use:

RewriteEngine On 
RewriteCond %{HTTP_HOST} http://www.currentsite.com/ [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot
RewriteRule ^(page1|page2|page3|etc)$ http://www.newsite.com/$1 [L,R=301]
like image 200
Croises Avatar answered Nov 24 '25 21:11

Croises



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!