Alias指令可能永远不会匹配,因为它与早期的Alias重叠

好吧,不知道为什么这是发生。

所以,我收到消息

The Alias directive in /etc/httpd/conf.d/awstats.conf at line 3 will probably never match because it overlaps an earlier Alias. 

 The Alias directive in /etc/httpd/conf.d/welcome.conf at line 18 will probably never match because it overlaps an earlier Alias. 

但是这里是我的/httpd/httpd.conf文件的前15行

 ServerSignature Off ServerTokens Prod ServerRoot "/etc/httpd" Listen *:80 Listen *:443 User apache Group apache ServerAdmin hostmaster@localhost ServerName 192.168.1.200:80 Include conf.d/*.conf <- THIS IS WHERE INCLUDES BEGIN Include conf.modules.d/*.conf 

在第14行之前绝对没有Alias or ScriptAlias条目,它是Include conf.d/*.conf

所以,实际上,第一次遇到Alias条目时,实际上是在awstats.conf下的awstats.conf文件中。

为什么我得到这个错误呢?

服务器运行,这只是一个烦恼。

编辑:在/etc/httpd/conf.d/*.conf上做了grep别名,这里是结果 – >

 /etc/httpd/conf.d/awstats.conf:Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/" /etc/httpd/conf.d/awstats.conf:Alias /awstatscss "/usr/share/awstats/wwwroot/css/" /etc/httpd/conf.d/awstats.conf:Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/" /etc/httpd/conf.d/awstats.conf:ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/" /etc/httpd/conf.d/welcome.conf:Alias /.noindex.html /usr/share/httpd/noindex/index.html /etc/httpd/conf.d/welcome.conf:Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css /etc/httpd/conf.d/welcome.conf:Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css /etc/httpd/conf.d/welcome.conf:Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif /etc/httpd/conf.d/welcome.conf:Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png 

最容易理解的是,Apache在内部生成一个单独的configuration文件,在继续下一行之前,逐行parsing主httpd.conf,并在IncludeIncludeOptional指令所在位置包含外部部分。

Include文件系统path中使用通配符时, Include按照辞典(词典)顺序parsing, conf.d/alice.conf将在conf.d/bob.conf之前。

随着许多指令的顺序问题,一些最后的事情被使用,与其他人一个更大的范围之前,一个较小的范围将赢得等。

Alias指令的规则是:

根据标准合并规则 ,不同情况下发生的别名和redirect与其他指令一样被处理。 但是,当多个别名或redirect发生在相同的上下文中(例如,在同一部分),它们按照特定的顺序进行处理。

首先, 在处理别名之前处理所有redirect ,因此匹配RedirectRedirectMatch匹配的请求将永远不会应用别名。 其次,别名和redirect按照它们在configuration文件中出现的顺序进行处理, 第一个匹配优先

出于这个原因,当这些指令中的两个或更多指令适用于相同的子path时,您必须首先列出最具体的path,以使所有指令具有效果。 例如,以下configuration将按预期工作:

 Alias /foo/bar /baz Alias /foo /gaq 

但是,如果上述两个指令顺序相反, /foo别名将始终匹配/foo/bar别名之前,所以后者的指令将被忽略。

对于一个很好的故障排除第一次开始你的情况是一个简单的grep -E "Alias|Redirect" conf.d/*.conf

我有不正确的主机configuration导致类似的错误。 要解决它只需添加:

 <VirtualHost *:80> Here Host Configuration </VirtualHost> 

检查configuration虚拟主机。 在我的情况下,错误导致了虚拟主机的错误configuration。 看起来像这样:/etc/apache2/sites-available/hitman.conf

 ServerAdmin marek@localhost ServerName hitman DocumentRoot /home/marek/public_html/hitman 

正确的configuration:

 <VirtualHost *:80> ServerAdmin marek@localhost ServerName hitman DocumentRoot /home/marek/public_html/hitman </VirtualHost>