Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have an ErrorDocument directive defined inside my .htaccess file:

ErrorDocument 404 /site/error.php

Now if I go to a non-existent page like this on my site it works fine:

However if I try go to a non-existent directory, the directive doesn't work

tries to find the document:

which of course doesn't exist. I've searched online and all sources indicate the second example above should go to the correct file (because the leading / in the directive makes it relative to the web root), but this is apparently not the case.

I am running on Ubuntu, thanks!

share|improve this question
up vote 1 down vote accepted

.htaccess files are evaluated relative to the directory that was requested. This is also true of directives inside <Directory > blocks inside your main configuration.

The simplest solution would be to move the ErrorDocument directive into your main Apache configuration instead of the .htaccess file.

share|improve this answer
+1 Thanks, this is exactly what I was looking for! – user491704 Dec 28 '11 at 19:26

Try disabling all modules. Try apache2ctl configtest. Post your apache2.conf.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.