My hosts structures look like this:
/var/www/host1/htdocs/
/var/www/host2/httpdocs/
/var/www/host3/public/
/var/www/host4/www/
etc.
I'd like to extend/enhance the following configuration with dynamically setting the document directory name (the last directory name of the whole path):
<VirtualHost *:80>
ServerAlias *.local
VirtualDocumentRoot "/var/www/%-2+/"
VirtualScriptAlias "/var/www/%-2+/"
</VirtualHost>
This confguration matches the following URLs:
test.local -> /var/www/test/
another.test.local -> /var/www/another.test/
projectname.local -> /var/www/projectname/
Every project has a different public folder name. As mentioned above some projects use htdocs
or httpdocs
, others use public
or www
etc, - you get the point.
I'd like to have Apache 2 automatically determine the existing public folder automatically and serve resources from within the determined directory:
test.local -> /var/www/test/public/
another.test.local -> /var/www/another.test/htdocs/
projectname.local -> /var/www/projectname/www/
Is this possible? As far as I know Apache 2 has no directives to check for existence of directories.
Is there a way to achieve what I have in mind or are there any modules/mods or tools to manage this?
Thanks a lot for any input! :)