我有一个自定义403页面forbidden.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不是我的强项
正确的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