The Alias directive will probably never match because it overlaps an earlier Alias
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
orRedirectMatch
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
Related videos on Youtube
fizzy drink
Updated on September 18, 2022Comments
-
fizzy drink over 1 year
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
fileServerSignature 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 theInclude conf.d/*.conf
.So, in reality, the first time an
Alias
entry is encountered, is in fact in theawstats.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
-
HBruijn over 9 yearsThanks but I just updated the debug command:
grep -E "Alias|Redirect" conf.d/*.conf
-
-
fizzy drink over 9 yearssame output. not sure what that means
-
HBruijn over 9 yearsThen I'm a bit lost too!
-
fizzy drink over 9 yearsOK, so I'm not the only one :)
-
kasperd about 8 yearsI find it very unclear what your proposed solution is.
-
Grzegorz Brzęczyszczykiewicz about 8 yearsA more detailed description of the problem solution. I hope that helps.