$_GET is empty on my ErrorDocument

In apache, I am using the following code to route 404s to a custom script.

ErrorDocument 404 /http404.php

I need to know the query string of the request. So if the user tries to hit "/invalid.php?var1=a&var2=b" I need the "var1=a&var2=b" to be available to http404.php. Unfortunately $_GET is always empty on http404.php.

Related tags: Apache PHP

Credit: print_r($_SERVER)

Under Apache, the query string of the 404 request can be accessed in $_SERVER['REDIRECT_QUERY_STRING']. To automatically populate $_GET, use these lines at the top of your script:


Rating: 3

Propose a different solution...