WampServer:403 Forbidden

时间:2018-02-02 11:08:17

标签: apache wampserver

我的本​​地WampServer虚拟主机突然无法正常工作。

我已为vhosts.confhosts添加了新的虚拟主机。

当我在网络浏览器中加载该虚拟主机时,我会收到403 Forbidden

vhosts.conf中,我有:

<VirtualHost *:80>
    ServerName example.com.au
    ServerAlias example.com.au
    DocumentRoot "D:\Dropbox\WAMP\WWW\example.com.au"
    <Directory  "D:\Dropbox\WAMP\WWW\example.com.au">
        Options Indexes FollowSymLinks MultiViews
        Require all granted
    </Directory>
</VirtualHost>

httpd.conf我有:

Listen 10.0.0.199:80 ::1
Listen [::0]:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>

其中10.0.0.199是我的PC的IP。

WampServer在线。

WampServer 3.0.6 Apache 2.4.23

帮助表示赞赏。

2 个答案:

答案 0 :(得分:0)

我改变了

<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory />
    AllowOverride none
    Require all granted
</Directory>
httpd.conf中的

,解决了403错误。

答案 1 :(得分:0)

httpd.conf中的默认配置包含您需要的所有Listen参数

Listen 0.0.0.0:80
Listen [::0]:80

这就是说在端口80上监听这个PC的IP地址是否适用于IPV4和IPV6地址范围,这就是你所需要的。

httpd.conf的这一部分也应该在您找到时保留。这会设置对安装WAMPServer(Apache)的驱动器上所有文件夹的所有权限的基本拒绝,并且应该这样做。将其更改回此

<Directory />
    AllowOverride none
    Require all denied
</Directory>

这是为了您的安全。它说没有人被允许访问此驱动程序的根目录,因此无法访问根目录下的任何内容。一旦设置完毕,您就应该打开只访问Apache实际需要访问的内容。这就是您在httpd-vhosts.conf文件中仅针对网站需要访问的文件夹所执行的操作。 如果你被黑了,那么黑客只能访问那些给定访问权限的文件夹而不是你的整个驱动器。

httpd-vhosts.conf shoudl中的虚拟主机定义如下所示

<VirtualHost *:80>
    ServerName example.com.au
    ServerAlias www.example.com.au
    DocumentRoot D:/Dropbox/WAMP/WWW/example.com.au
    <Directory  "D:/Dropbox/WAMP/WWW/example.com.au/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All

        ## Dangerous unless you really mean to 
        ## allow the universe into your server
        ## I would use one of the other options and comment this one out
        Require all granted

        # If access from this PC only then us
        # i.e. you are a standalone developer
        # uncomment this
        #Require local

        #If access from your local network is required
        # i.e. you are working with other devs within your local network
        # uncomment this
        #Require ip 10.0.0

    </Directory>
</VirtualHost>
  

请注意,使用Unix正斜杠和<Directory....标记需要一个尾部斜杠

然后检查您的HOSTS文件它应该是这样的

127.0.0.1 localhost
::1 localhost
127.0.0.1 example.com.au
::1 example.com.au
相关问题