I have a custom error page that is just HTML/CSS and some JS that will take the query string (?error=404 for example) and display dynamic content based on that query string, with a generic fallback if none is supplied. I want this query string to be passed by the .htaccess ErrorDocument redirect but unfortunately it does not.
ErrorDocument 404 /error.html?error=404
This displays the generic error page as I assume it is truncating the query string. It does return a 404 status however, which is what I need.
I could obviously redirect to the absolute URL and maintain the query string but then I'd get a 200 header, which is no good!
Any help would be much appreciated!
If you use this technique only to always use the same page with all error codes, but find the correct code (in your case 404
), you will always find this code in the variable (php): $_SERVER["REDIRECT_STATUS"]