【发布时间】:2016-10-12 22:27:12
【问题描述】:
我在本地 Windows 机器上的 xampp 上设置了 3 个虚拟主机。 (见下面的配置)
每当我将浏览器定向到 stage.local 或 host.local 时,我都会被重定向到 dev.local,这是我首先设置的虚拟主机,但不应该是默认虚拟主机。
但是,当我转到 host.local/index.php 时,会显示正确的文件,不知何故它只是根目录搞砸了。 我不确定这怎么可能或如何解决。
配置似乎正确,这是完整文件:
#
# Use name-based virtual hosting.
#
NameVirtualHost *
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
<VirtualHost *>
ServerAdmin webmaster@host.local
DocumentRoot "C:/xampp/htdocs/host.local/"
ServerName host.local
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@stage.local
DocumentRoot "C:/xampp/htdocs/stage.local/"
ServerName stage.local
ErrorLog "logs/stage.local-error.log"
CustomLog "logs/stage.local-access.log" common
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@dev.local
DocumentRoot "C:/xampp/htdocs/dev.local/"
ServerName dev.local
ErrorLog "logs/dev.local-error.log"
CustomLog "logs/dev.local-access.log" common
</VirtualHost>
httpd -S 是这样说的:
*:* is a NameVirtualHost
default server host.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:29)
port * namevhost host.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:29)
port * namevhost stage.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:35)
port * namevhost dev.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:43)
(之后的一些 ssl 内容)
我的主机文件有以下条目:
127.0.0.1 localhost
127.0.0.1 host.local
127.0.0.1 stage.local
127.0.0.1 dev.local
【问题讨论】: