Reputation: 147
I have a .htaccess
file that rewrite .php
to .htm
:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s
RewriteRule .* %1.htm [L,R=301]
RewriteRule ^(.*)\.htm$ $1.php
The redirect works fine, But the redirection looses the $_POST
data. How to keep $_POST
data while redirecting?
Upvotes: 0
Views: 1062
Reputation: 47976
If you want to simply rewrite the URL from .php
files to .htm
files, all you'll need to do is something like this -
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s
RewriteRule ^(.*)\.php$ $1.htm
The 3 lines of the .htaccess
detail the flowing behavior -
.htm
file.Upvotes: 0
Reputation: 798686
Browsers convert a POST request into a GET request on redirect. The RFC states that they should instead prompt the user if the method needs to change, but none of them follow that and instead force the method change unconditionally.
Upvotes: 1