Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up a service where clients can sign up and a subdomain will be automatically made for them as part of their account.

After looking high and low on google i came onto an apache page detialing Mass Virtualhost and similar solutions.

My problem is that I can't make heads or tails from the examples and i'm not sure how it all works.

The end result i want www to be always pointing to /var/www/vhosts/ while * always points to /var/www/vhosts/

is this possible?

share|improve this question
up vote 2 down vote accepted

So you want to go to /var/www/vhosts/ ? Try it like this:

Put this in /var/www/vhosts/

ServerAlias *
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com
RewriteCond /var/www/vhosts/ -d
RewriteRule ^(.*) /%1/$1 [L]
share|improve this answer
would i need to remove my A record that points * to my host IP? – Eli May 12 '11 at 20:47
No, it's just fine :-) – Bart De Vos May 12 '11 at 22:26

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.