并非所有参数都存在时的 VirtualDocRoute

VirtualDocRoute when not all params are present

我已经在我们的共享主机箱上设置了大量虚拟主机,并在 apache2.conf 文件中使用以下指令:

VirtualDocumentRoot /www/hosts/%3+/%2/%1/public

因此,例如:

www.domain.com ==> /www/hosts/com/domain/www/public/
www.domain.co.uk==> /www/hosts/co.uk/domain/www/public/

问题是如果裸域指向我的服务器,我不知道文档路由在哪里。

我的想法是:

domain.com ==> /www/hosts//com/domain/public/

as %3+ 匹配为空(域只有 2 个元素)。但是,如果我将 index.html 文件放在那里进行测试,它似乎不是设置 DocumentRoot 的位置。

任何想法都可以

a) 当 VirtualDocumentRoot 模式中缺少参数时,DocumentRoot 所在的位置

b) 如果域中只有 2 个部分存在(忽略 2 个 TLD,例如“.co.uk”grrrrr)如何设置不同的 VirtualDocumentRoot)

谢谢,

蒂姆

The docs

If N or M [those being the numbers in a %N.M interpolation term] is greater than the number of parts available a single underscore is interpolated.

所以也许试试 /www/hosts/_/com/domain/public/