Reputation: 2013
I'm currently trying to configure Apache vhost configuration and was hoping to be able to use mod_vhost_alias for everything.
Instead of setting up a configuration for each website I wanted to make it dynamic.
So far I have:
VirtualDocumentRoot /home/%-2.0.%-1.0/www
Which works fairly well, but I would like to be able to allow sub-domains so i tried the following:
VirtualDocumentRoot /home/%-2.0.%-1.0/www/%-3.0
But I don't want the DocumentRoot to be /home/example.com/www/www
Is there a way to achieve this? If not, would my best option to use mod_rewrite for subdomains?
Upvotes: 1
Views: 94
Reputation: 98
You can add a ServerAlias before the VirtualDocumentRoot to catch the www. subdomain:
ServerAlias www.*
VirtualDocumentRoot /home/%-2.0.%-1.0/www
The top example would catch all www. subdomains.
To have the server behave as desired for all other subdomains, add another ServerAlias for all other subdomains like:
ServerAlias *
VirtualDocumentRoot /home/%-2.0.%-1.0/www/%-3.0
Hope this helps
Upvotes: 0