Forum Moderators: phranque
The script work fine as do the 403 errors. But the custom error page is not displayed, just the default one.
Using CPanel, I created a custom error page for 403 errors. This is easy enough. CPanel creates a file in the root folder with the custom error information and calls it whateveriwant.shtml (or whatever).
I was advised to alter the end of my nad bot script rewrite rule from this;
RewriteRule .* - [F]
To something like this;
RewriteRule!^whateveriwant\.shtml$ - [F]
Or have I got that wrong?
Thanks for any help.
Otherwise, say a user-agent or IP address is forbidden, and the server attempts to send your custom 403 error page as a response. If that custom 403 error page is not excluded from your rule, then it too will be forbidden, because the requesting user-agent or IP address is still forbidden. So, the server again attempts to send the custom 403 error page in response to this second error, and again gets a 403 error -- and you've got an 'infinite' loop there.
So, your rule should be
RewriteRule !^whatever-your-custom-403-page-is-named\.whatever-type-file-it-is$ - [F]