ServerAlias
simply declares alternative names that can be used to address the same site (or <VirtualHost>
. So if I have
ServerName www.example.com
ServerAlias example.com
I will see the same content for both http://www.example.com/foo/
and http://example.com/foo/
.
However, if the Apache server needs to issue a redirect for any reason (for example from a directory name without a trailing slash to the corresponding name with the slash), the behaviour depends on the UseCanonicalName setting. If this is unspecified or Off
then it will do what you would expect (http://example.com/foo
-> http://example.com/foo/
) but if it is set to On
then the redirect will be to the ServerName
regardless of the original request URL (i.e. http://example.com/foo
-> http://www.example.com/foo/
). Check if you have this set in your configuration.