虚拟主机无法正确解析

时间:2012-11-15 13:57:41

标签: apache vhosts

我有以下vhosts配置:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/projects/mycheck.il"
    ServerName mobile.mycheck
    ErrorLog "logs/mobile.mycheck.log"
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/projects/api.il"
    ServerName api.mycheck
    ErrorLog "logs/api.mycheck.log"
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/projects/admin"
    ServerName front.mycheck
    ErrorLog "logs/front.mycheck.log"
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ErrorLog "logs/localhost.log"
</VirtualHost>

并使用Windows,我有以下主机文件

127.0.0.1       localhost
127.0.0.1       mobile.mycheck
127.0.0.1       api.mycheck
127.0.0.1       front.mycheck

但是,无论我尝试将哪个vhost放入浏览器,我总是会解析到同一个目录(projects/mycheck.il),任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

尝试在VirtualHost声明之前添加以下行:

NameVirtualHost *:80