This doesn't work:
ErrorDocument 401 ../../src/wrong_pwd.php
it renders the path as text, it really prints
../../src/wrong_pwd.php
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?
The docs say:
../../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 theDocumentRoot
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: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 whichinclude()s
the/path/to/src/wrong_pwd.php
...)Have you tried a symlink?