php - ErrorDocument redirection from any directory to a file with relative links - most compact way -
i have php file works custom message displayer. pass variables , displays message based on that. works 404 error page. problem is; has relative references, highly desirable because of portability, don't seem work, after errordocument
redirection file.
file's location: /a/b/c/custom_message_displayer.php
when httpd.conf
set to:
errordocument 404 /a/b/c/custom_message_displayer.php?e=404
and error comes subdirectory eg. /a/blah
, active directory in case /a/
, not /a/b/c/
errordocument
redirecting, , results in mislinking in file (relative css, js, include() paths).
i made workaround uses additional file. i'm concerned this, , wonder if there's more simple way of doing this. perhaps httpd.config
-based redirection changes active directory?
the workaround:
errordocument 404 /additional_file.php
→ file redirects using: header('location: /a/b/c/custom_message_displayer.php')
preserving/forwarding query.
the file gets executed in it's directory, , relative links work.
is there simplier way of doing above? bit of advice.
Comments
Post a Comment