Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: httpd.apache.org/docs/current/mod/core.html#errordocument –  LazyOne Sep 8 '11 at 21:55

2 Answers 2

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

 
discard

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.