【问题标题】:What is the difference between ServerName and ServerAlias in apache2 configuration?apache2 配置中的 ServerName 和 ServerAlias 有什么区别?
【发布时间】:2013-08-24 02:30:54
【问题描述】:
我正在配置我的 apache2 服务器,我想知道 ServerName 和 ServerAlias 之间有什么区别。
ServerName 是否总是像 google.de 一样不带 www 的名称
ServerAlias 是 www.google.de
即使是这样,我也不明白 :) 对不起。
我不是专业人士(现在)所以感谢您的帮助!每个帮助都会立即投票。
【问题讨论】:
标签:
configuration
apache2
webserver
ubuntu-12.04
【解决方案1】:
来自Documentation:
ServerName:
服务器用来标识自己的主机名和端口
ServerAlias:
将请求与名称虚拟主机匹配时使用的主机的备用名称
大多数人只是简单地使用ServerName 设置网站的“主”地址(例如“mywebsite.com”)并使用ServerAlias 添加网站将绑定到的其他地址(例如“www.mywebsite” .com')。
然而,两者之间存在细微差别:
-
ServerName 也可以接受端口号,而ServerAlias 不能。
-
ServerAlias 可以接受通配符(例如 *.mywebsite.com),而 ServerName 不能。
阅读文档以了解原因。