Answer the question
In order to leave comments, you need to log in
How to preserve query parameters when redirecting via ErrorDocument in .htaccess?
Found that the parameters of get and post requests are lost
if the direction is via ErrorDocument.
For example, the content of .htaccess is:ErrorDocument 404 /test.php
Content of test.php
echo '$_REQUEST:<br />';
var_dump($_REQUEST);
echo '<br />';
echo '$_POST:<br />';
var_dump($_POST);
echo '<br />';
echo '$_GET:<br />';
var_dump($_GET);
echo '<br />';
echo '<br />--------------------<br />';
echo 'POST-TEST:<br />';
echo '<form action="" method="post">
<input type="text" name="bla" /><br />
<input type="submit" value="Send" />
</form>';
Answer the question
In order to leave comments, you need to log in
In general, the answer is apparently - no way:
Here they write:
The bottom line is to use the Error Document directive to redirect all non-existent requests to one script.
The main significant disadvantage of Error Document is the impossibility of intercepting POST data!
To receive POST data form a form action to a real URL.
Also, the disadvantages include the fact that the error.log of the server is clogged, which prevents the identification of real errors that need to be fixed.
In this case, the request will go directly to test.php, which is logical,
and redirection to ErrorDocument will not occur.
The question is how to save the parameters of the request passing through the ErrorDocument
In the .htaccess file we write:
ErrorDocument 404 /404.php
and, here you can play with this file: <?php
echo "<xmp>";
print_r($GLOBALS);
For all requests, it prints a dump of PHP environment variables. How to handle variable values is a matter of taste. Among these variables will be your parameters (except perhaps the body of the POST request). Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question