Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/domain.com/httpdocs while *.domain.com always points to /var/www/vhosts/domain.com/httpdocs/members

is this possible?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

So you want http://awesomesauce.domain.com to go to /var/www/vhosts/domain.com/httpdocs/awesomesauce ? Try it like this:

Put this in /var/www/vhosts/domain.com/conf/vhost.conf

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

Your Answer

 
discard

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.