首页 文章

当DocumentRoot指向两个不同的驱动器时,Apache为我提供了403 Access Forbidden

提问于
浏览
50

尝试在vhost下打开页面时,我获得了403访问权限,其中文档根位于与apache所在位置不同的驱动器上 . 我使用apachefriends发布安装 . 这是我的httpd-vhosts.conf文件:

NameVirtualHost 127.0.0.1 

 <VirtualHost 127.0.0.1>
  ServerName foo.localhost
  DocumentRoot "C:/xampp/htdocs/foo/public"
</VirtualHost> 

 <VirtualHost 127.0.0.1>
  ServerName bar.localhost
  DocumentRoot "F:/bar/public"
</VirtualHost>

在我的浏览器中打开bar.localhost时,Apache正在给我403 Access Forbidden . 我尝试设置了许多不同的访问权限,甚至是对所有人的完全权利,但我尝试过没有任何帮助 .

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

4 回答

  • 57

    你不需要

    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

  • 0

    在某个地方,您需要告诉Apache,允许人们查看此目录的内容 .

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

    More info

  • 24

    对于 Apache 2.4.2 :当我试图通过WiFi上的iPhone从我的Windows 7桌面访问WAMP时,我得到了403:持续禁止 . 在一个blog上,我找到了解决方案 - 在<Directory>部分中的Allow all之后添加 Require all granted . 这就是我的<Directory>部分在<VirtualHost>中的样子

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

    我修复了以下代码

    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>
    

    它的功效就像魅力一样

相关问题