403 .htaccess中的403错误

I have a custom 403 page forbidden.php

I have added it to .htaccess but not working

<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>

I have also tried:

<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>

What am I missing. .htaccess is not my strong point

The correct ErrorDocument syntax is:

ErrorDocument <3-digit-code> <action>

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

Actually it's not mod_rewrite dependent, you could put the ErrorDocument outside of the condition.

Also, are you trying to achieve a 404 custom document with rewrite rules???

Just use that, done.

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