redirect a domain using htaccess permenantly
Question
I am having a site with two domains pointing to the same site.
Lets say domain1.com
& domain2.com
I want to do a permanent redirect of the domain1.com
to domain2.com
, so that anyone who visit the site from domain1 even if Google crawler, it should be redirected to the domain2. I want to do this from htaccess. Is it possible?
Solution
Yes, it's possible.
put in your .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)domain1.com [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow