As far as I know switching the values of the ServerName
and ServerAlias
normally makes no difference in how your sites will operate.
As mentioned in the manual only when UseCanonicalName
is set to a non-default value, you'll see the value of ServerName (rather than whatever URL was used to reach your site) getting used when creating self-referential redirection URL's.
You'll see self-referential redirection URL's for instance if the users type a ServerAlias hostname and a URL which is a directory, such as http://www.example.com/splat
, without the trailing slash, then Apache httpd will redirect them to http://example.com/splat/
.
Otherwise you'll only see the value of the ServerName directive in the output of apachectl -S
and in error messages as the standard templates for friendly error messages include the ServerName from include/bottom.html
to customise them:
Title: 404 Not Found
Not Found
The requested URL /some/page was not found on this server.
Apache/2.2.15 (CentOS) Server at example.com port 80
There are some valid technical arguments to use www.example.com
and you may want to do this instead:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / www.example.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ServerAlias www.example.org www.example.net
# ...
</VirtualHost>