Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict direct access to error pages

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?

like image 410
Eyad Fallatah Avatar asked Dec 12 '11 01:12

Eyad Fallatah


1 Answers

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

like image 90
Book Of Zeus Avatar answered Nov 15 '22 08:11

Book Of Zeus