Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Apache and ErrorDocument.

9:43 am on Jun 3, 2003 (gmt 0)

New User

10+ Year Member

joined:June 3, 2003
votes: 0


I have many directories, and for some of them, i would like to specify a personalized 404 error. So i would make a different .htaccess and 404.html for each directory. How could i make it?

Actually :
.htacces (http://domain.com/dir1/):
Authname "X"
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
<limit GET POST>
require valid-user
ErrorDocument 401 [domain.com...]
ErrorDocument 403 [domain.com...]
ErrorDocument 404 [domain.com...]

Where is the problem?

PS : I'm on a shared server, i coudn't touch to the httpd.conf...

4:26 pm on June 3, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0


Welcome to WebmasterWorld [webmasterworld.com]!

I am not sure what problem you are having, if any. However, the syntax of your ErroDocument statements is incorrect, and will result in 302-Moved Temporarily status being returned by your server, rather than the desired server status code (401, 403, 404, etc.).

If you read the Apache ErrorDocument Documentation [httpd.apache.org], there is a paragraph warning about this problem. You can also confirm the problem using the WebmasterWorld Server Headers checker [webmasterworld.com].

In order to return the correct server status code, you must use a local path in your ErrorDocument directives:

ErrorDocument 401 /error/dir1/401.html
ErrorDocument 403 /error/dir1/403.html
ErrorDocument 404 /error/dir1/404.html

You may create different .htaccess files to handle errors for each of your (sub)directories, or you may centralize all error handling in your "main" .htaccess file in your web root directory - whichever you like. The server will check each .htaccess file along the path to the requested resource, and process whichever applicable ErrorDocument directive it finds first.


6:51 am on June 4, 2003 (gmt 0)

New User

10+ Year Member

joined:June 3, 2003
votes: 0

Thanks a lot :), it works.

I was sure to test with this syntax but i would have another problem last time. Now it works fine.