2

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!

2

.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.

1
  • +1 Thanks, this is exactly what I was looking for! – user491704 Dec 28 '11 at 19:26
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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