I'm using a VirtualDocumentRoot setting on my dev system, so I can easily work on multiple projects without updating the VirtualHosts all over the time.
That currently looks like that:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www VirtualDocumentRoot /var/www/%1 ServerName everything.localhost ServerAlias *.localhost </VirtualHost>
So I can access the directories below /var/www e.g. by calling foobar.localhost.
The problem is that I now also have projects which are working with a different document root directory, e.g. have another src, pub or public folder in the repository so I want to use these, but that differs per project. So the idea was to extend the VirtualDocumentRoot with another level:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www VirtualDocumentRoot /var/www/%1/%2 ServerName sub.everything.localhost ServerAlias *.*.localhost </VirtualHost>
So I can call these project e.g. with src.foobar.localhost. Unfortunately that conflicts with the previous rule so I can no longer access the "old" projects which don't have an extra subdirectory.
Is there a way of dealing with both of these VirtualHosts/VirtualDocumentRoots in one apache configuration?
An idea I already had was to have another base domain, like localhost2 for the subdirectories, so the ServerAlias would only match that rule, but that's not the preferred solution.