I want to redirect ONLY users from website1 pages to website2 homepage. The google bot and other crawlers must indexing and do not know about redirection. Can you help me?

I know how to place the permanent redirect, but how to add a condition to be only for users?


I want to redirect the whole website to another one with .htaccess. The redirect must be valid only for visitors without web crawlers and bots. I want the Googlebot and other crawlers to continue indexing and viewing the old website without being redirected.

For example, if I put:

RewriteEngine on 
RewriteCond %{http_host} ^www.website1.com [NC,OR] 
RewriteCond %{http_host} ^website1.com [NC] 
RewriteRule ^(.*)$ http://website2.com/ [R=301,NC,L]

In the .htaccess file, all visitors from website1 will be redirected to website2 homepage. Robots and search engines will continue to index without being redirected to website2?

  • 2
    You know that's bad SEO right? Trying to trick Google into seeing a different website than humans is just asking for a penalty. – Andrew Lott Dec 1 '17 at 23:09
  • Yes, I know that. But what is the way to create the condition for the redirect? – PetarST Dec 2 '17 at 0:41
  • If you update your question with an explanation of why you want to do this, then you may get some useful answers. – Andrew Lott Dec 17 '17 at 21:22

Browse other questions tagged or ask your own question.