ErrorDocument in .htaccess, is it possible to use relative path?
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
...)