Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

now days I create two files one for and one for because the wild card * doesn't work right for accessing my question is how do I make redirect to using apache and not something like php. So I can have one virtual host configuration per domain.

share|improve this question

1 Answer 1



in your virtual host configuration...

Then you can redirect non-www to www with something like:

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  RewriteCond %{HTTP_HOST} (.+)$ [NC]
  RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
share|improve this answer

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.