I am configurating my apache2 server and I wonder whats the difference between ServerName and ServerAlias.
Is the ServerName always a name without www as like google.de and the ServerAlias is www.google.de
Even if it's like this, I don't get it :) sorry.
I am not a professional (now) so thank you for your help! Every help will upvoted immediately.
ServerName - If the host part of the HTTP request matches this name, then allow the request. Normally this would be a domain name that maps to an IP, but in this case the HTTP request host must match this IP. ServerAlias - Alternate names accepted by the server.
IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers.
Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses.
From the Documentation:
ServerName
: Hostname and port that the server uses to identify itself
ServerAlias
: Alternate names for a host used when matching requests to name-virtual hosts
Most people simply use ServerName
to set the 'main' address of the website (eg. 'mywebsite.com') and ServerAlias
to add additional addresses the website will be bound to (eg. 'www.mywebsite.com').
Yet, there are subtle differences between the two:
ServerName
can accept port numbers as well, while ServerAlias
cannot.ServerAlias
can accept wildcards (eg. *.mywebsite.com), while ServerName
cannot.Read the documentation to understand why.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With