Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

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.

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

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

share|improve this answer
add comment

Your Answer

 
discard

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.