WAMP 上的虚拟主机导致 403 在 192.168.1.6 上被禁止......其他别名仍然有效

Virtual Hosts on WAMP causing 403 forbidden on 192.168.1.6… other aliases still work

最近修改了 httpd.conf 和 httpd-vhosts.conf 以添加虚拟主机...

    #IncludeOptional "E:/wamp/vhosts/*"
Include "E:/wamp/alias/*"

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "e:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "e:/wamp/www">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require local
        Require ip 192.168.1
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot E:/activeWork/projects
    ServerName projects.local
        <Directory  "E:/activeWork/projects">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require local
    </Directory>

</VirtualHost>
<VirtualHost *:80>
    DocumentRoot E:/activeWork/projects
    ServerName www.projects.local
        <Directory  "E:/activeWork/projects">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot E:/activeWork/projects
    ServerName api.projects.local
        <Directory  "E:/activeWork/projects">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

之后,当我尝试加载 192.168.1.6 或 127.0.0.1 时,给我:

Forbidden

You don't have permission to access / on this server.

我已经尝试用 this answer 解决它,但对我不起作用

然后 在回答中我检查了我的 access.log 结果是这样的:

192.168.1.6 - - [03/Oct/2016:11:03:00 +0330] "GET / HTTP/1.1" 403 288
127.0.0.1 - - [03/Oct/2016:11:00:55 +0330] "GET / HTTP/1.1" 403 286

如果你确定你的wamp安装路径在E:里面 那么我建议你检查你的访问日志和错误日志以收集更多信息。

我假设您在 Wampserver 上使用的是 Apache 2.4 或更高版本?如果是这样,请在您的虚拟主机中用 "Require all granted" 替换 require 规则,如下所示:

<VirtualHost *:80>
    DocumentRoot "e:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "e:/wamp/www">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

如果还是不行,请检查您的防火墙是否阻止了您的访问。

我的问题是定义 3 个 vhost 指向同一个目录,这让 apache 感到困惑...最后 tnx 到 riggsfolly i fixed that...beside of this i make changes from this guide to define VHost 以正确的方式设置东西