I want to make general rule for all my domains, so I don't have to specify each of them individually.

I have these two lines in my Apache config file:

RewriteCond   %{HTTP_HOST} ^domain\.com
RewriteRule   ^(.*)$ http://www.domain.com/$1 [R=301,QSA]

Now I have more domains pointing to the same directory. And I would have to repeat these 2 lines for each domain. I was trying to edit this condition and rule, but with no success to make them general to any domain without actually specifying domain name. Is it possible ?

link|improve this question

78% accept rate
feedback

1 Answer

To redirect everything except www.domain.com (since that would be a loop) to www.domain.com, you'd want something like this:

RewriteCond   %{HTTP_HOST} !^www\.domain\.com$
RewriteRule   ^(.*)$ http://www.domain.com/$1 [R=301,QSA]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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