简体   繁体   English

带有*通配符的apache 2.4 serverAlias会覆盖特定的vhost

[英]apache 2.4 serverAlias with * wildcard overwrittes specificed vhost

I have two vhosts the default one and another one: 我有两个虚拟主机,默认为一个,另一个为:

<VirtualHost *:80>
    ServerName www.eve-stuff.com
    ServerAlias *.eve-stuff.com
    DocumentRoot /var/www/html/test
    <Directory /var/www/html/test>
        Options +FollowSymLinks
        AllowOverride None
        #Require all denied
    </Directory>
</VirtualHost>

This one should just redirect all subdomains that a not specifically setup to the test directory. 这应该只将所有未专门设置的子域重定向到测试目录。 This is another vhost i have: 这是我拥有的另一个虚拟主机:

<VirtualHost *:80>
        ServerName dev.eve-stuff.com
        DocumentRoot /var/www/html/dev 
        <Directory /var/www/html/dev>
                Options +FollowSymLinks
                AllowOverride None
        </Directory>
</VirtualHost>

This one should show the dev folder for the dev subdomain. 这应该显示dev子域的dev文件夹。

From what I understood from the apache doc the ServerAlias *.eve-stuff.com in the first host will always catch UNLESS another vhost has specifically been created for the address. 根据我从apache文档中ServerAlias *.eve-stuff.com ,第一个主机中的ServerAlias *.eve-stuff.com将始终捕获,除非专门为该地址创建了另一个vhost。

However dev.eve-stuff.com still redirects to the test folder not to the dev folder, as it should. 但是dev.eve-stuff.com仍然重定向到测试文件夹,而不是重定向到dev文件夹。

All dns entries, also for the subdomains, point to the right IP. 所有dns条目(也包括子域)都指向正确的IP。 I am running Apache/2.4.18 (Ubuntu). 我正在运行Apache / 2.4.18(Ubuntu)。

Turns out the order in which it is setup matters. 证明设置顺序很重要。 Apache apparently looks for the matching host it can find. Apache显然会寻找它可以找到的匹配主机。
Since the first config was in 000-default.conf and the second one was in the 020-dev.conf the dev-subdomain matched the first vhost and used that. 由于第一个配置位于000-default.conf ,第二个配置位于020-dev.conf因此dev-subdomain匹配了第一个虚拟主机并使用了它。
I changed default to 999-default.conf which means now dev will first be matched with the proper vhost but other undefined subdomains will still be matched with the default vhost. 我将default更改为999-default.conf ,这意味着现在dev将首先与正确的虚拟主机匹配,但其他未定义的子域仍将与默认虚拟主机匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM