Home >Backend Development >PHP Tutorial >How to Redirect POST Data Without Losing It?
Redirecting POST Data: A Solution
In this scenario, the website automatically redirects all requests to the index.php file, enabling the display of the appropriate page using PHP. The question arises as to whether this redirection also allows for the submission of POST data to a designated address.
To maintain the POST data, the .htaccess rule can be modified. The original rule, which effectively dropped all POST data:
RewriteRule send-mail index.php?send-mail [NC,L]
can be replaced with the following:
RewriteRule send-mail index.php?send-mail [NC,P]
The addition of the "P" flag serves two purposes:
This modification ensures that POST data is preserved during the redirection to index.php.
The above is the detailed content of How to Redirect POST Data Without Losing It?. For more information, please follow other related articles on the PHP Chinese website!