apache2.4中通配符子域的Virtualhost通配符子域

问题描述 投票:0回答:1

目前,我已经像下面这样使用通配符子域配置:

<VirtualHost *:80>
    ServerAlias *.domain
    ErrorLog /tmp/error.log
    CustomLog /tmp/access.log combined
    VirtualDocumentRoot /var/www/%1/public
<Directory "/var/www">
    DirectoryIndex index.php
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

但是如果我输入sub.sub.domain,将返回默认的虚拟主机。如何配置到主/根域的路径?我在conf下尝试过,但仍然没有用:

<VirtualHost *:80>
    ServerAlias *.*.domain
    ErrorLog /tmp/error.log
    CustomLog /tmp/access.log combined
    VirtualDocumentRoot /var/www/%2/public
<Directory "/var/www">
    DirectoryIndex index.php
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

我将%2更改为%1仍然无法正常工作。

什么是正确的语法?

apache apache2 subdomain virtualhost vhosts
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.