ServerName vs ServerAlias

The ServerName directive is

Hostname and port that the server uses to identify itself

Whilst ServerAlias is

Alternate names for a host used when matching requests to name-virtual hosts

Given a vhost configured like


ServerName example.com
ServerAlias www.example.com foo.example.com *.somewherelse.org

apache would respond to example.com, www.example.com foo.example.com and anything in .somewherelse.org with this VirtualHost