【问题标题】:Application of DirectoryIndex to an Alias in Apache在 Apache 中将 DirectoryIndex 应用于别名
【发布时间】:2013-03-23 07:45:05
【问题描述】:

如何将 DirectoryIndex 应用于 Apache 中的别名而不导致错误 403?

这会导致响应标头 200:

http://localhost/ 哪个呈现 http://localhost/index.html

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    DirectoryIndex index.html index.php index.xhtml index.htm default.htm
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

这会导致错误 403,禁止:

http://localhost/aliasName/wwwrootDevelopmentSubDirectory/

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    DirectoryIndex index.html index.php index.xhtml index.htm default.htm
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    Alias /aliasName/ "/home/user/Dropbox/Level1/Level2/wwwrootDevelopment/"
    <Directory /home/user/Dropbox/Level1/Level2/wwwrootDevelopment>
            DirectoryIndex index.html index.php index.xhtml index.htm default.htm
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>

error.log 显示在浏览器中看到的相同消息。

[Tue Apr 02 00:19:30 2013] [error] [client 172.x.x.x] (13)Permission denied: access to /aliasName/wwwrootDevelopmentSubDirectory/ denied, referer: http://localhost/

【问题讨论】:

    标签: apache alias directoryindex


    【解决方案1】:

    别名的目录索引应该在 apache2 中该别名的特定指令中

    Alias /pma "/var/www/pma"
    <Directory "/var/www/pma">
        DirectoryIndex adminer.php
         Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 2014-09-28
      • 2015-09-04
      • 2020-11-20
      • 2011-09-27
      • 1970-01-01
      • 2017-08-13
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多