APACHE下多个域名绑定到一个目录的方法

五月 01, 2019 | views
Comments 0

有时我们做全国分站时会碰到要一个目录绑定多个二级域名了,那么在apache中要怎么快速绑定呢,下面我来给各位分享一下经验.

http.conf中如何修改,比如域名分别为www.site1.com;site1.com;www.phpfensi.com;目录为D:/PC_webserver/phproot/site 下面标准写法该如何写?代码如下:

ServerName www.phpfensi.com

DocumentRoot "D:/PC_webserver/phproot/site"

解决方法,代码如下:

  1. ServerName www.phpfensi.com 
  2.  
  3. ServerAlias site1.com 
  4.  
  5. ServerAlias www.site1.com 
  6.  
  7.  
  8. DocumentRoot "D:/PC_webserver/phproot/site" 

其实还有一种办法,我们直接这样改进,代码如下:

  1. <VirtualHost 192.168.1.108:108> 
  2.     ServerAdmin webmaster@dummy-host.www.phpStudy.net 
  3.     DocumentRoot "E:wwwcgd" 
  4.     ServerAlias www.phpfensi.com phpfensi.com 
  5. </VirtualHost> 

中间以空格分开即可.



zend