Note that there are some explanatory texts on larger screens.

plurals
  1. POErrorDocument redirection from any directory to a file with relative links - most compact way
    primarykey
    data
    text
    <p>I have a php file that works like a custom message displayer. I pass some variables with GET and it displays a message based on that. It also works as a 404 error page. The problem is; it has <strong>relative</strong> references, which are highly desirable because of portability, but they don't seem to work, after my <code>ErrorDocument</code> redirection to that file.</p> <p>file's location: <code>/a/b/c/custom_message_displayer.php</code></p> <p>When <code>httpd.conf</code> is set to:</p> <p><code>ErrorDocument 404 /a/b/c/custom_message_displayer.php?e=404</code></p> <p>and the error comes from a subdirectory eg. <code>/a/blah</code>, the <strong>active</strong> directory is in this case <code>/a/</code>, not the <code>/a/b/c/</code> to where <code>ErrorDocument</code> is redirecting, and that results in mislinking in the file (relative css, js, include() paths).</p> <p>I made a workaround that uses an additional file. But i'm concerned about this, and wonder if there's some more simple way of doing this. Perhaps an <code>httpd.config</code>-based redirection that also changes the active directory?</p> <p>The workaround:</p> <p><code>ErrorDocument 404 /additional_file.php</code> → this file redirects using: <code>header('Location: /a/b/c/custom_message_displayer.php')</code> also preserving/forwarding the GET query.</p> <p>The file then gets executed in it's directory, and all relative links work.</p> <p>Is there a simplier way of doing the above? Thanks for any bit of advice.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload