Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have the following which redirects and to perfectly.

RewriteCond %{HTTP_HOST} !^(.*)\.mydomain1\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

I am trying to add an additional rule for a second domain, that will redirect all non www traffic for to


share|improve this question

migrated from Jul 8 '11 at 11:16

This question came from our site for professional and enthusiast programmers.

1 Answer 1

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} [OR]
RewriteCond %{HTTP_HOST}
RewriteRule ^(.*)$$1 [R=301,L]

RewriteCond %{HTTP_HOST}
RewriteRule ^(.*)$$1 [R=301,L]

These rules will only work with domains/subdomains described in your question and will not catch any other subdomains (e.g. will not trigger these rules).

share|improve this answer
+1 you are more of a htaccess Jedi then I – John Conde Jul 8 '11 at 14:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.