Apache 虚拟主机:对域的请求由默认目录提供

Apache 虚拟主机:对域的请求由默认目录提供

对我的域名 leanback.eu 的请求由默认页面 (/var/www/default) 提供,而不是由 /var/www/leanback_eu 提供。这是怎么回事?其他虚拟主机运行良好。我的机器的主机名是 leanback.eu...

000-默认:

NameVirtualHost *:80
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/default/
        <Directory /var/www/default/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/error_default.log

        # debug, info, notice, warn, error, crit, alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access_default.log combined
</VirtualHost>

leanback_eu:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName leanback.eu
    DocumentRoot "/var/www/leanback_eu/"
    ErrorLog "/var/log/apache2/error_leanback_eu.log"
    CustomLog /var/log/apache2/access_leanback_eu.log combined


    <Directory "/var/www/leanback_eu/">
        Order allow,deny
        Allow from all
        AllowOverride All
     </Directory>
<Directory /var/www/leanback_eu/stats>
                Options Indexes
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

$ sudo apache2 -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
default server leanback.eu (/etc/apache2/sites-enabled/000-default:2)
port 80 namevhost leanback.eu (/etc/apache2/sites-enabled/000-default:2)
port 80 namevhost kexx.net (/etc/apache2/sites-enabled/kexx_net:77)
port 80 namevhost leanback.eu (/etc/apache2/sites-enabled/leanback_eu:1)

这可能非常简单......

答案1

您的第一个虚拟主机容器没有ServerName指令,这导致它成为一个捕获所有主机的容器。为其添加一个名称(您想要的任何默认值),但将附件更改为读取<VirtualHost _default_:80>而不是,*:80这样您就可以开始了。它仍然是默认的,但现在其他的也会匹配,而不是卡在没有名称的匹配所有主机上。

相关内容