Context: Redirect XHR POST requests to another WordPress API on a sub-domain using htaccess
and maintaining POST data.
Note
Using a 307
compares to 302
but forces the client to preserve $_POST
data. Similarly, 308
compares to 301
but with $_POST
data preservation. Using temporary redirect makes more sense since an API request is being redirected instead of the new location of a static resource.
When comparing 308
and 307
, a 307
is older and better supported. Furthermore, in the context where these conclusions are gathered from, response times are ~1200ms versus ~250ms, respectively. Values are averages of each redirect type tested three times.
Solution
.htaccess
code for redirecting POST requests to a subdomain using 307 code. Edit accordingly.
Redirect 307 /request/from/static/frontend https://cms.website.com/target/url
References
- Information on RFC 7538 >> RFC Editor
- Redirect request with POST data using .htaccess | Kalpesh Mehta
- php – Is it possible to redirect post data? – Stack Overflow
- Redirecting API requests and post data using htaccess | Jay Gould
Did this solve your issue?
RIGHT NOW THIS HAS HELPED 0% WEBSITE VISITORS.
TOTAL VOTES: 0