【问题标题】:ErrorDocument 403 is not accessible by its 403 access deny in ApacheApache 中的 403 访问拒绝无法访问 ErrorDocument 403
【发布时间】:2021-07-19 00:23:48
【问题描述】:

我在我的 Apache 服务器中在 httpd.conf 处实施了一个全局 IP 块,显示禁止 IP 403 错误文档,但无法访问 403 错误文档,因为禁止 IP 的访问再次被拒绝,因此他们看不到403 错误文档由 403 错误。它说403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

<Directory "${SRVROOT}/htdocs">
    Options FollowSymLinks 
    AllowOverride None
    <RequireAll>
        Require all granted
        Include conf/banlist.conf
    </RequireAll>
    ErrorDocument 403 "/error403.php"
</Directory>

<Location />
    <RequireAll>
        Require all granted
        Include conf/banlist.conf
    </RequireAll>
    ErrorDocument 403 "/error403.php"
</Location>

这是我在httpd.conf 中的访问控制代码。我应该在哪里处理它以允许被禁止的 IP 访问 403 文档而不禁用全局 IP 块?

【问题讨论】:

    标签: apache apache2.4


    【解决方案1】:

    要允许被禁止的 IP 访问 403 错误文档,您应该创建一个目录并将其配置为不同的访问级别。先制作errorpages目录,在httpd.conf中实现这段代码。

    <Directory "${SRVROOT}/htdocs/errorpages">
        Require all granted
    </Directory>
    <Location /errorpages>
        Require all granted
    </Location>
    

    另外,您需要将ErrorDocument 403 "/error403.php" 更改为ErrorDocument 403 "/errorpages/error403.php"

    <Directory "${SRVROOT}/htdocs">
        Options FollowSymLinks 
        AllowOverride None
        <RequireAll>
            Require all granted
            Include conf/banlist.conf
        </RequireAll>
        ErrorDocument 403 "/errorpages/error403.php"
    </Directory>
    
    <Location />
        <RequireAll>
            Require all granted
            Include conf/banlist.conf
        </RequireAll>
        ErrorDocument 403 "/errorpages/error403.php"
    </Location>
    

    然后他们可以看到 403 错误文档,但仍然不允许他们看到您服务器中的其他页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      • 2017-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多