Answer the question
In order to leave comments, you need to log in
Why are requests from the POST method redirected to GET?
Site on wordpress.
I added api to htaccess:
RewriteCond %{REQUEST_URI} ^/api/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ api/api.php [QSA,L]
Answer the question
In order to leave comments, you need to log in
It turns out that Apache, when making a POST request to a folder URL without a trailing slash, redirects to a URL with a slash, and the request is transformed into a GET. If you put a slash, then the effect disappears.
Conclusion: In the action of the form, always put a slash at the end of the folder URL, or better, use the file URL.
It turns out such a scheme
1. We send a POST to mysite/mydir
2. The server answers us with 301 to mysite/mydir/ (why this is correct is described in the Apache documentation)
3. The browser makes a GET without parameters to mysite/mydir/ (that's right to do, this is described in RFC 2616)
As a result, instead of our POST with parameters, we get a GET without parameters. Everything is logical, but somewhat unexpected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question