LAMP为单一站点设置多域名

有时候我们需要为某一站点设置多个域名,比如eliyar.biz以及www.eliyar.biz都均指向本博客。

先按照DigitalOcean VPS配置多站点LAMP设置后,尝试了一下设置都失败

ServerName eliyar.biz www.eliyar.biz

ServerName eliyar.biz,ww.eliyar.biz

最后发现这种方式配置行得通

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<VirtualHost *:80>
ServerName eliyar.biz
DocumentRoot /var/www/eliyar_biz

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
LogLevel notice

ErrorLog /var/www/eliyar_biz/error.log
#CustomLog /var/www/eliyar_biz/access.log combined
</VirtualHost>

<VirtualHost *:80>
ServerName www.eliyar.biz
DocumentRoot /var/www/eliyar_biz
</VirtualHost>