多个主机名,相同的域,不同的虚拟主机

时间:2012-06-08 13:48:01

标签: apache2

我正在尝试根据主机名称(不是域名)将请求路由到不同的docroots:

 <VirtualHost 123.123.12.12:80>
 SuexecUserGroup "#521" "#521"
 ServerName forum.somesite.net
 DocumentRoot /home/somesite/public_html/forums
 </VirtualHost>

 <VirtualHost 123.123.12.12:80>
 SuexecUserGroup "#521" "#521"
 ServerName www.somesite.net
 DocumentRoot /home/somesite/public_html
 </VirtualHost>

虽然不行。无论主机名是什么,Apache似乎都会转到第一个条目。我做错了什么?

1 个答案:

答案 0 :(得分:0)

尝试将第二个虚拟主机更改为此

 <VirtualHost 123.123.12.12:80>
  SuexecUserGroup "#521" "#521"
  ServerName somesite.net
  ServerAlias www.somesite.net
  DocumentRoot /home/somesite/public_html
 </VirtualHost>