Httpd – The Alias directive will probably never match because it overlaps an earlier Alias

apache-2.4centos7httpdmod-alias

Ok, not sure why this is occuring.

So, I get the message

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

and

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

but here are the first 15 lines of my /httpd/httpd.conf file

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

There are absolutely no Alias or ScriptAlias entries before line 14, which is the Include conf.d/*.conf.

So, in reality, the first time an Alias entry is encountered, is in fact in the awstats.conf file under /conf.d/*.conf.

Why is it that I am getting this error then?

The server runs, it's just an annoyance.

EDIT: did grep Alias on /etc/httpd/conf.d/*.conf and here are the results ->

/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

Best Answer

The easiest to understand is that Apache generates a single configuration file internally, by parsing the main httpd.conf line by line and includes the external sections at the locations where the Include or the IncludeOptional directive is used, before continuing with the next line.

When wildcards are used in Include file-system paths the includes are parsed in lexicographical (dictionary) order, conf.d/alice.conf will come before conf.d/bob.conf.

With many directives order matters, with some the last occurrence is used, with others a greater scope before a smaller scope will win etc.

The rules for the Alias directive are:

Aliases and Redirects occurring in different contexts are processed like other directives according to standard merging rules. But when multiple Aliases or Redirects occur in the same context (for example, in the same section) they are processed in a particular order.

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

For this reason, when two or more of these directives apply to the same sub-path, you must list the most specific path first in order for all the directives to have an effect. For example, the following configuration will work as expected:

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

But if the above two directives were reversed in order, the /foo Alias would always match before the /foo/bar Alias, so the latter directive would be ignored.

For troubleshooting a good first start in your case is a simple grep -E "Alias|Redirect" conf.d/*.conf