1

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?

Eli
  • 427
  • 2
  • 7
  • 19

1 Answers1

2

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]
Bart De Vos
  • 18,061