To start with, we wanted a request to *.example.com
to be handled by a corresponding /var/www/*/
directory, and we have got this working by using mod_vhost_alias
with VirtualDocumentRoot
, as follows:
<VirtualHost *:80>
ServerAlias *.example.com
UseCanonicalName Off
VirtualDocumentRoot /var/www/%1/
</VirtualHost>
Now we want to expand on this shared configuration by applying the same RewriteRules to all subdomains / directories - from within the vhost configuration's <Directory>
block - but we do not know how to reference the subdomain / directory.
We're basically trying to do something like this (note the use of %1, which doesn't work in this case):
<VirtualHost *:80>
ServerAlias *.example.com
UseCanonicalName Off
VirtualDocumentRoot /var/www/%1/
<Directory /var/www/%1>
RewriteEngine on
RewriteRule ^about/?$ index.php?view=about
RewriteRule ^settings/?$ index.php?view=settings
RewriteRule ^support/?$ index.php?view=support
</Directory>
</VirtualHost>
Is something like this possible?
Thanks.