LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   .htaccess 403/404.html not working properly (https://www.linuxquestions.org/questions/linux-server-73/htaccess-403-404-html-not-working-properly-679287/)

Nemie 10-27-2008 04:52 AM

.htaccess 403/404.html not working properly
 
Hi, I have been trying to fix with my .htaccess files to restrict access to some catalogs on my webserver.

The problem is that the .html files I created only works when I type:
http://skutt.net/error_pages/
On that link the 404/403.html shows up.
On other sites like:
http://skutt.net/.files/

I just get the plain:
Code:

Forbidden

You don't have permission to access /.files/ on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

This is how the .htaccess file looks like:
Code:

ErrorDocument 404 /error_pages/404.html
ErrorDocument 403 /error_pages/403.html
order allow,deny
deny from all

The /error_pages/ lies in the root of skutt.net /var/www/html/skutt.net/.

What have I done wrong?

dkm999 10-28-2008 10:09 PM

My reading of the order directive says that you ought to have this instead of what you have in your .htaccess file:
Code:

ErrorDocument 404 /error_pages/404.html
ErrorDocument 403 /error_pages/403.html
order allow,deny
allow from all

The reason is that Apache does not stop processing allow and deny directives when it gets a match. It processes all that it can find that apply to the object in question, and only then decides what to do. In the case here, it processes allow directives first, deny directives second. If at least one allow match occurs and no deny matches occur, access is allowed. But since deny directives are processed last, if any one of them matches, it does not matter that a previous allow directive matched; the request will be denied anyway.


All times are GMT -5. The time now is 01:28 AM.