apache无法解析虚拟主机中的根域

时间:2014-04-09 01:04:15

标签: apache

阅读http://httpd.apache.org/docs/current/vhosts/name-based.html部分内容如下:

If no matching ServerName or ServerAlias is found in the set of virtual hosts containing the most specific matching IP address and port combination, then the first listed virtual host that matches that will be used.

我有一个包含许多虚拟主机域的vhost文件。问题是,当我输入我的服务器IP时,我应该转到root但是没有,我被带到第一个列出的虚拟主机,如apache文档所述。

那我该怎么做呢?如何防止键入我的服务器IP,用户将被带到我的vhost文件中的第一个虚拟主机规则?

2 个答案:

答案 0 :(得分:0)

您的第一个项目通常应该是localhost并解析为该根... - Feras 19秒前编辑。这是应该命名的第一个vhost条目,服务器应该是localhost。

答案 1 :(得分:0)

你不能这样做。一旦开始定义虚拟主机,它将始终是一个虚拟主机,它生成的响应不是"外部默认值" DocumentRoot的。

因此,只需在虚拟主机列表的顶部创建一个新的虚拟主机(因此它将成为默认的虚拟主机),然后将其文档设置为您希望默认文档为的内容。