Apache让一台虚拟主机接受多域名解析

之前写了一篇文章关于linux下apache虚拟主机配置,配置那是相当简单:

 

  1. <VirtualHost *:80>
  2. ServerAdmin [email protected]
  3. DocumentRoot /var/www/html/blog
  4. ServerName blog.phpddt.com
  5. ErrorLog /var/log/httpd/blog/error_log
  6. CustomLog /var/log/httpd/blog/access_log common
  7. </VirtualHost>

 

如果你想让多个域名解析到该虚拟主机(也就是该目录),ServerAlias就是接受多域名解析的,如上例我想把xxx.phpddt.com也解析到上面目录的话: 

 

  1. <VirtualHost *:80>
  2. ServerAdmin [email protected]
  3. DocumentRoot /var/www/html/blog
  4. ServerName blog.phpddt.com
  5. ServerAlias xxx.phpddt.com
  6. ErrorLog /var/log/httpd/blog/error_log
  7. CustomLog /var/log/httpd/blog/access_log common
  8. </VirtualHost>

 

另外还可以接受三级、四级。。。或泛解析:

ServerAlias *.phpddt.com

你可能感兴趣的:(apache)