Morgan
Morgan

Reputation: 31

.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

Upvotes: 3

Views: 4351

Answers (2)

Croises
Croises

Reputation: 18671

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]

Upvotes: 4

Al.G.
Al.G.

Reputation: 4387

Create a robots.txt in your main folder with this content:

User-agent: *
Disallow: /page_to_hide1
Disallow: /page_to_hide2
Disallow: /page_to_hide3

Find more information here:
https://support.google.com/webmasters/answer/6062608?hl=en http://www.robotstxt.org/robotstxt.html

Upvotes: -1

Related Questions