Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
apache未解析虚拟主机中的根域_Apache - Fatal编程技术网

apache未解析虚拟主机中的根域

apache未解析虚拟主机中的根域,apache,Apache,阅读中有一部分写道: 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文件。

阅读中有一部分写道:

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文件中的第一个virtualhost规则?

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

您不能这样做。一旦开始定义虚拟主机,它将始终是生成响应的虚拟主机,而不是“外部默认”documentroot


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

但是如果我使用IP打开网站?将virtualhost创建为localhost会起作用吗?您希望被带到哪里?我希望被带到我的根public_html