What is the difference between ServerName and ServerAlias in apache2 configuration?

前端 未结 1 910
庸人自扰
庸人自扰 2020-12-30 02:14

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 goo

相关标签:
1条回答
  • 2020-12-30 02:43

    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.

    0 讨论(0)
提交回复
热议问题