0

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! :)

thasmo
  • 9,159
  • 6
  • 27
  • 32
  • This sounds like you are looking for a "mass vhost solution". There are specialized modules for this, I think. There is no direct way to create such a dynamic configuration in apache, since a host configuration needs to be evaluated at startup time. – arkascha Feb 15 '14 at 16:21
  • Hi there! I've already dug into the topic for a while and generally the mass hosting topic isn't the problem but more specifically having a different document folder name for each vhost, without appending this folder name in the domain. – thasmo Feb 15 '14 at 16:26

0 Answers0