: Htaccess and 301 redirects - multiple domains I have the following which redirects mydomain1.co.uk and mydomain1.com to www.mydomain1.com perfectly. RewriteCond %{HTTP_HOST} !^(.*).mydomain1.com$ [NC]
I have the following which redirects mydomain1.co.uk and mydomain1.com to mydomain1.com perfectly.
RewriteCond %{HTTP_HOST} !^(.*).mydomain1.com$ [NC]
RewriteRule ^(.*)$ www.mydomain1.com/ [R=301,L]
I am trying to add an additional rule for a second domain, that will redirect all non www traffic for mydomain2.com to mydomain2.com.
Thanks!
More posts by @Phylliss660
1 Comments
Sorted by latest first Latest Oldest Best
You seems to have quite a few domains and subdomains pointing to the same folder (so they share the same .htaccess) which makes your original approach not suitable for such situation. Use these rules instead of yours:
RewriteCond %{HTTP_HOST} =mydomain1.co.uk [OR]
RewriteCond %{HTTP_HOST} =mydomain1.com
RewriteRule ^(.*)$ www.mydomain1.com/ [R=301,L]
RewriteCond %{HTTP_HOST} =mydomain2.com
RewriteRule ^(.*)$ www.mydomain2.com/ [R=301,L]
These rules will only work with domains/subdomains described in your question and will not catch any other subdomains (e.g. hello.mydomain1.com will not trigger these rules).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.