.htaccess 301 redirect only for Google bots

71 Views Asked by At

What code do I need to add to .htaccess to redirect my old domain to the new one, but to do this not for users, but only for the google bot. I have a variant of the code, but it doesn't work. It gives canonical to the old domain.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^googlebot
RewriteRule ^(.*)$ http://new-domain.com/$1 [L,R=301]
0

There are 0 best solutions below