【问题标题】:403 Error in .htaccess.htaccess 中的 403 错误
【发布时间】:2015-09-17 02:00:36
【问题描述】:

我有一个自定义的 403 页面 disabled.php

我已将其添加到 .htaccess 但无法正常工作

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^notfound\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound.php [L]
ErrorDocument 403 . /forbidden.php
</IfModule>


<Files 403.shtml>
order allow,deny
allow from all
</Files>

我也试过了:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^notfound\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound.php [L]
</IfModule>


<Files forbidden.php>
order allow,deny
allow from all
</Files>

我错过了什么。 .htaccess 不是我的强项

【问题讨论】:

    标签: php apache .htaccess


    【解决方案1】:

    正确的ErrorDocument 语法是:

    ErrorDocument <3-digit-code> <action>
    

    http://httpd.apache.org/docs/2.4/custom-error.html

    实际上它不依赖于mod_rewrite,您可以将ErrorDocument 放在条件之外。

    另外,你是不是想实现一个带有重写规则的404自定义文档???

    使用它,完成。

    ErrorDocument 404 /nofound.php
    ErrorDocument 403 /forbidden.php
    

    【讨论】:

      猜你喜欢
      • 2011-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-19
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多