mod_vhost_alias and VirtualDocumentRoot: 如何添加倒数第二个和最后一部分?
mod_vhost_alias and VirtualDocumentRoot: How to add penultimate and last part?
如何获取由域名后两部分组成的目录名。还是用点?
例如,我有一个域 any.ms,我想要动态域 foo.any.ms 和域 bar.any.ms 也指向 /var/www/dev/any.ms/public 目录。或者域any.lorem.ipsum.ms指向目录/var/www/dev/ipsum.ms/public.
我的 ms.conf 目前(不工作,apache 无法启动):
<VirtualHost *:80>
ServerAlias *.ms
VirtualDocumentRoot /var/www/dev/%-2%.%-1/public
UseCanonicalName Off
<Directory "/var/www/dev">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
我使用文档 http://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html 但我无法插入点 /%-2.%-1/, /%-2 %.%-1/, /%-2\.%-1/.
我刚刚找到了解决方案:
If you want to include the . (dot) character in a VirtualDocumentRoot directive, but it crashes with a % directive, you can work around the problem in the following way:
VirtualDocumentRoot /usr/local/apache/vhosts/%2.0.%3.0
工作解决方案:
<VirtualHost *:80>
ServerAlias *.ms
VirtualDocumentRoot /var/www/dev/%-2.0.%-1.0/public
UseCanonicalName Off
<Directory "/var/www/dev">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
如何获取由域名后两部分组成的目录名。还是用点?
例如,我有一个域 any.ms,我想要动态域 foo.any.ms 和域 bar.any.ms 也指向 /var/www/dev/any.ms/public 目录。或者域any.lorem.ipsum.ms指向目录/var/www/dev/ipsum.ms/public.
我的 ms.conf 目前(不工作,apache 无法启动):
<VirtualHost *:80>
ServerAlias *.ms
VirtualDocumentRoot /var/www/dev/%-2%.%-1/public
UseCanonicalName Off
<Directory "/var/www/dev">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
我使用文档 http://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html 但我无法插入点 /%-2.%-1/, /%-2 %.%-1/, /%-2\.%-1/.
我刚刚找到了解决方案:
If you want to include the . (dot) character in a VirtualDocumentRoot directive, but it crashes with a % directive, you can work around the problem in the following way:
VirtualDocumentRoot /usr/local/apache/vhosts/%2.0.%3.0
工作解决方案:
<VirtualHost *:80>
ServerAlias *.ms
VirtualDocumentRoot /var/www/dev/%-2.0.%-1.0/public
UseCanonicalName Off
<Directory "/var/www/dev">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>