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

This doesn't work:

ErrorDocument 401 ../../src/wrong_pwd.php

it renders the path as text, it really prints


and doesn't output the real file.

If I put the absolute path it will render the contents of /var/www/home (I don't really know why, maybe it's something in httpd.conf?)

How can I do that?

share|improve this question

The docs say:

URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser.

../../src/wrong_pwd.php doesn't begin with a slash so I expect Apache treats it as a message. It looks like you can't return a document which is outside the DocumentRoot so I suspect what you want will never work (this is sensible; after all, the client has to be able to retrieve the document in case of an error).

You might be able to use Alias to alias the error page to a location outside the document root. Something like:

Alias /error/wrong_pwd.php /path/to/src/wrong_pwd.php
ErrorDocument 401 /error/wrong_pwd.php

Untested, YMMV, etc. You might need to explicitly grant access to this directory with a <Directory> block; see the mod_alias documentation. Of course, there are security concerns here -- generally you don't want to expose your source to the world. (If this is the case perhaps you could make a lightweight, web-visible PHP wrapper which include()s the /path/to/src/wrong_pwd.php...)

share|improve this answer
Yes I'm going to use a wrapper, the problem is I can't catch this error properly. Using alias gives an error on error.log: Alias not allowed here... – Andrea Ambu Aug 5 '09 at 9:02

Have you tried a symlink?

ln -s ../../src/wrong_pwd.php src/wrong_pwd.php
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.