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

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

share|improve this question
NO -- documentation clearly shows what can be used as a value there and no variable parsing/replacement is performed: – LazyOne Sep 8 '11 at 21:55
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.

share|improve this answer

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.

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.