I am using .htaccess to show custom HTML page for errors (401, 404, 500 .. etc). I want to restrict direct access to the errors folder which contains the html pages. Inside of the .htaccess file of the errors folder, I have the following:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com
RewriteRule \.(html|htm)$ - [F]
This does not really seem to work and I get:
a 500 Internal Server Error error was encountered while trying to use an
ErrorDocument to handle the request.
What changes do I have to make to the .htaccess file to get this to work. I am also wondering if it would work if I stick the errors folder outside of the public_html folder?
Here's what you should put in your .htaccess (in your public_html)
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^(www\.)?mydomain\.com
RewriteRule \.(html|htm)$ - [F]
Let me know if it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With