If I have an .htaccess file in a given directory within my website, and want to specify an ErrorDocument relative to the .htaccess file, NOT relative to the document root, is this possible?

Something like: ErrorDocument 404 $CURRENT_DIRECTORY/404.php

link|improve this question

67% accept rate
NO -- documentation clearly shows what can be used as a value there and no variable parsing/replacement is performed: httpd.apache.org/docs/current/mod/core.html#errordocument – LazyOne Sep 8 '11 at 21:55
feedback

2 Answers

up vote 2 down vote accepted

While a number of directives are sensitive to relative directory while within an .htaccess or <Directory> context, ErrorDocument is not. Per the documentation:

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

link|improve this answer
feedback

You could create a "master" 404.php that's used for all 404s, then within that file include the specific 404.php using a path determined by the request, an environment variable (set with SetEnv), etc.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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