Reputation: 1
We're having an issue routing our website to it's new domain. We have a total of 3 domains.
domain1.com domain2.com domain3.com
Where domain3.com is the new domain that domain1.com and domain2.com need to directed to.
Our current .htaccess file is setup link so:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.domain1\.com [OR]
RewriteCond %{HTTP_HOST} ^domain1\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com [OR]
RewriteCond %{HTTP_HOST} ^domain2\.com [OR]
RewriteCond %{HTTP_HOST} ^domain3\.com.com
RewriteRule ^(.*)$ http://www.domain3.com/$1 [R=permanent,L]
RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
What's working:
domain2.com successfully redirects to domain3.com
domain3.com successfully goes to domain3.com
What's not working:
domain1.com DOES NOT redirect to domain3.com
What must be changed in the htaccess file to get domain1.com to also redirect permanently to domain3.com?
Thank you in advance!
Upvotes: 0
Views: 272
Reputation: 786319
You can use this code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?(domain1|domain2)\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain3.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Upvotes: 0