我试图解决这个问题,所以请帮助我。
我有几个虚拟主机configuration和使用Debian的默认configuration虚拟主机的方式。
2个文件夹
并且一些文件被符号链接到使用ln -s ...
启用的站点ln -s ...
并且在这个步骤中,我重命名这些文件以具有权重200 -… 300 -…来具有优先权。
当我尝试configuration一堆虚拟主机时:
<VirtualHost test.host.priv:80> ServerName test.host.priv DocumentRoot "/htdocs/Private/web/production/somedomain/web" </VirtualHost> <VirtualHost host.com:80> ServerName host.com ServerAlias www.host.com DocumentRoot "/htdocs/Private/web/production/somedomain/web" </VirtualHost>
现在我有几个,我也有一些*:80
。 但是,如何确保这些只听我指定的服务器名称? 因为apache开始使用这些作为通配符等。在这种情况下,每个域的Loke默认返回到test.host.priv,如果它没有被configuration在一个更高优先级的文件。 我不希望这样,我试过使用*:80
, test.host.priv:80
,它只是不在乎,它仍然默认为这个,所以没有指定的任何子域去这里。
任何build议将是伟大的!
/马库斯
当NameVirtualHost
在特定的监听器上激活时,Apache通过ServerName
和ServerAlias
匹配VHosts,我想这就是你在这里所缺less的。
使用Debian时,你将有一个默认为Listen 80
的ports.conf
,这意味着在所有可用的接口上侦听端口80。 然后你可以使用NameVirtualHost *:80
并写你的主机,如:
<VirtualHost *:80> ServerName test.host.priv DocumentRoot "/htdocs/Private/web/production/somedomain/web" </VirtualHost> <VirtualHost *:80> ServerName host.com ServerAlias www.host.com DocumentRoot "/htdocs/Private/web/production/somedomain/web" </VirtualHost>
你可以随意改变它,只需要<VirtualHost [something]:[someport]>
需要一个“匹配的” NameVirtualHost [something]:[someport]
。
有关详细信息,请参见http://httpd.apache.org/docs/2.2/mod/core.html#NameVirtualHost 。