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:

http://mysite.com/p

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

http://mysite.com/random/hello

tries to find the document:

http://mysite.com/random/site/error.php

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!

link|improve this question

60% accept rate
feedback

2 Answers

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.

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

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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