Rewrite Rule for Multiple Domains To Display Only One

Avatar
  • Answered
I have looked but cannot find a complete answer to this, or the preferred method.

We have one main domain call it domain.co.uk with a rewrite rule in .htaccess so that www.domain.co.uk goes to domain.co.uk. We also have three other parked domains that go to the same page but display as the url the relevant domain. What we want to do is for those other domains to display the domain.co.uk url in the address bar even if they have the www prefix as per above. I have found this on the web:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^decorativeconcreteofva.com$ [OR]
RewriteCond %{HTTP_HOST} ^decorativeconcreteofcentralvirginia.com$ [OR]
RewriteCond %{HTTP_HOST} ^decorativeconcreteva.com$ [OR]
RewriteCond %{HTTP_HOST} ^decorativeconcretevirginia.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.decorativeconcreteofva.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.decorativeconcreteofcentralvirginia.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.decorativeconcreteva.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.decorativeconcretevirginia.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.decorativeconcreteofcentralva.com$ [OR]
RewriteCond %{HTTP_HOST} ^decorativeconcreteofcentralva.com$
RewriteRule ^(.*)$ http://www.decorativeconcreteofvirginia.com/$1 [R=301]

but is this the best way to do it and as we will be going to SSL/TLS in a few months will it make any difference?
Avatar
Arn
Hello Bigbunny,

Thanks for the question about the redirect rewrite statement for your website. Typically, if you are being explicit with a re-direct and want it to be re-written a certain each time a condition is matched, then this is the best way to make that happen. Changing to HTTPS will not make a difference as your code will still change the URL to the domain. You will need UPDATE the rewrite to use HTTPS if you want that URL to be the destination URL.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.