APACHE2如何里一个站点绑定多个域名?用ServerAlias
以前很笨,要使多个域名指向同一站点总是这样写:
<VirtualHost *:80>
ServerAdmin i@cdsy.xyz
DocumentRoot /www/cdsy.xyz
ServerName cdsy.xyz
</VirtualHost>
<VirtualHost *:80>
ServerAdmin i@cdsy.xyz
DocumentRoot /www/cdsy.xyz
ServerName www.cdsy.xyz
</VirtualHost>
<VirtualHost *:80>
ServerAdmin i@cdsy.xyz
DocumentRoot /www/cdsy.xyz
ServerName abc.cdsy.xyz
</VirtualHost>
这样一来就等于绑了多少域名就开了多少虚拟主机…………
后来看了看书,发现有个叫”ServerAlias“的东西可以用
其实可以这样:
<VirtualHost *:80>
ServerAdmin i@cdsy.xyz
DocumentRoot /www/cdsy.xyz
ServerName cdsy.xyz
ServerAlias www.cdsy.xyz abc.cdsy.xyz
</VirtualHost>
要绑多少个域名都可以写在 ServerAlias 后面,用空格隔开即可