I'm trying to configure dynamic virtual hosts with Apache and vhost_alias but I can't figure out how to do this:
I'd like to set my path like this:
/var/www/vhosts/example.com/www -> example.com /var/www/vhosts/example.com/www -> www.example.com /var/www/vhosts/example.com/sub -> sub.example.com /var/www/vhosts/example.com/sub.foo -> sub.foo.example.com /var/www/vhosts/example.com/sub.foo.bar -> sub.foo.bar.example.com
So I configured the Virtual Host like this:
UseCanonicalName Off <VirtualHost *:80> VirtualDocumentRoot /var/www/vhosts/%-2.0.%-1.0/%-3+ </VirtualHost>
%-2.0 gets all the penultimate part (2nd level domain) %-1.0 gets all the last part (Top Level domain) %-3+ gets everithing else before that
The question is: How do I tell apache to serve me the files into www when asking for the domain without www as 3rd level?
The paths work fine except when I try to reach the website without www