VirtualDocumentRoot的dynamic子目录

我在我的开发系统上使用了VirtualDocumentRoot设置,所以我可以轻松地在多个项目上工作,而不需要随时更新VirtualHost。

目前看起来像这样:

<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www VirtualDocumentRoot /var/www/%1 ServerName everything.localhost ServerAlias *.localhost </VirtualHost> 

所以我可以通过调用foobar.localhost访问/ var / www下面的目录。

问题是,我现在也有项目正在处理不同的文档根目录,例如在存储库中有另一个src,pub或公用文件夹,所以我想使用这些,但每个项目不同。 所以这个想法是将VirtualDocumentRoot扩展到另一个层次:

 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www VirtualDocumentRoot /var/www/%1/%2 ServerName sub.everything.localhost ServerAlias *.*.localhost </VirtualHost> 

所以我可以使用src.foobar.localhost调用这些项目。 不幸的是,这与以前的规则冲突,所以我不能再访问没有额外的子目录的“旧”项目。

有没有办法在一个Apacheconfiguration中处理这两个VirtualHosts / VirtualDocumentRoots?

我已经有一个想法是有另一个基本的域名,如子目录localhost2,所以ServerAlias只会匹配该规则,但这不是首选的解决scheme。

将实际的根目录符号链接到原始的虚拟主机目录?

 ln -sTv /var/www/fullrepo-project.localhost/pub /var/www/project.localhost