当尝试在虚拟主机下打开页面时,我收到 403 访问禁止,其中文档根目录与 apache 位于不同的驱动器上。我使用 apachefriends 版本安装。这是我的 httpd-vhosts.conf 文件:


NameVirtualHost 127.0.0.1

u003CVirtualHost 127.0.0.1>servername foo.localhost document root“ c:/xampp/htdocs/foo/public”u003C/VirtualHost>

u003CVirtualHost 127.0.0.1>servername bar.localhost document root“ f:/bar/buppl”u003C/VirtualHost>

当我在浏览器中打开 bar.localhost 时,Apache 给出了 403 Access Forbidden。我尝试设置许多不同的访问权限,甚至为每个人设置完全权限,但我尝试的任何方法都没有帮助。

编辑:谢谢!为了将来参考,请添加“选项索引”以显示目录索引。

有帮助吗?

解决方案

你不需要

Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted

你唯一需要的是...

Require all granted

...在目录部分内。

查看Apache 2.4升级方面:

http://httpd.apache.org/docs/2.4/upgrading.html

其他提示

在某个地方,您需要告诉 Apache 人们可以查看此目录的内容。

<Directory "F:/bar/public">
    Order Allow,Deny
    Allow from All
    # Any other directory-specific stuff
</Directory>

更多信息

为了 阿帕奇2.4.2: :我正在得到 403:禁止 当我尝试通过 WiFi 从 iPhone 访问 Windows 7 桌面上的 WAMP 时,会持续出现此问题。在一个 博客, ,我找到了解决方案 - 添加 要求全部授予允许全部 在里面 <目录> 部分。这就是我的 <目录> 部分看起来像在 <VirtualHost> 内

<Directory "C:/wamp/www">
    Options Indexes FollowSymLinks MultiViews Includes ExecCGI
    AllowOverride All
    Order Allow,Deny
    Allow from all
    Require all granted
</Directory>

我已经通过删除下面的代码来修复它

C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf 文件

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
 </VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

并添加了

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

它就像魅力一样起作用

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top