I'm doing some special error pages but because of things, they're one hop away though, meaning all that's left in the address bar is a cleaned up address with a 3-character-long path.

I want to, hopefully, do something like this:

  • Client attempts to get resource
  • Resource ain't there / server fails; 404, 503, etc… thus,
    • Server (Apache httpd) serves:
      • In {httpd|apache2}.conf: ErrorDocument 503 http://xxx/503.html?ref={someMagicMacroCodeOrSomething}
    • If not attended directly by Apache then the proxy (HAProxy) can intercept the server's response and do a more powerful redirection-decomposition-voodoo,
      • 303 redirect, HAProxy can easily alter the URL, maybe even send it as POST request, or,
      • 200, with meta refresh, JavaScript, maybe. IDK.
        — Even internally, most things go through the proxy in order to inject CSPs to prevent unvetted web apps from loading thing from third party domains. This is more likely.
  • Server hosting the error page serves it (as 200) with the URL that triggered the redirect in some sort of placeholder surrounded by gorgeous graphics or perhaps something out of a hospital's guest Wi-Fi, but at least more useful than a page without reference or the stock error codes.
    — It's okay for the user to know about the 400/500 error, that's the whole point, but it's not okay for the user agent to know about the error.

The final page, or the server for that matter, is not supposed to process the information passed along from the referrer page; I read this might be make this a vulnerability that could be use to inject stuff, fortunately I don't need to run analytics or anything with this, it's meant to inform the user only, it doesn't even need to be sent to the server at all – although I'm failing to see how, considering it's the server the one that would've had initiated the redirect in this case, right? — it could be something client-side only. The only requisite is to show the address it was redirected from.

Ideally, any static site web server should be enough to host the error documents. That rules out PHP, Node.js, .NET Core-d--duo-ultra..whatever cumbersome thing Microsoft is pushing lately. So… bare NGINX, or Apache httpd (with standard modules if needed), but it seems like it can do a lot of things just on its own, e.g; mod_status, Dynamic Shared Objects, and JavaScript I suppose, as long as it does not relies and the browser's history data or any invasive means.

Is this possible at all? I appreciate your advice on this, other suggestions are welcome too. Thanks!

1 Answer 1


Normally with Apache, you can instruct it to deliver a custom 404 page and show a friendly message to the user. Edit your .htaccess or httpd.conf file and add:

ErrorDocument 404 /error404.html

However, as I understand, you want to show a 200 code instead without using any scripted languages. In that case, you can try to add this to your .htaccess instead to achieve the desired result:

Redirect 200 /error404.html
ErrorDocument 404 /error404.html

Finally, in order to print the URL that was missing on the users' screen, you need some JavaScript to manipulate the DOM and show the URL of your custom 404 page.

The end result is easier done with a scripted language (like PHP) but you requested not to go in that route.

Credit: https://stackoverflow.com/questions/15083481/how-can-i-replace-apache-http-code-404-to-200

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