I need to change a behavior of third party PHP application and to revert changes back shortly after that. If I could rewrite GET requests and make POST ones out of them, I would save a lot of time and could avoid making any changes in the application.
Is it possible to transform GET http://website/action1?param=1
into POST http://website/action2
, with param being part of post request, using .htaccess?
Although, I can redirect the first GET request to a new page which will do POST to the second URL automatically (Javascript), I want to keep number of browser-server interactions as low as possible.
mod_rewrite. The RewriteBase directive specifies the URL prefix to be used for per-directory (htaccess) RewriteRule directives that substitute a relative path.
Use a 301 redirect . htaccess to point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain.
RewriteRule specifies the directive. pattern is a regular expression that matches the desired string from the URL, which is what the viewer types in the browser. substitution is the path to the actual URL, i.e. the path of the file Apache servers. flags are optional parameters that can modify how the rule works.
Is it possible to transform GET
http://website/action1?param=1
into POSThttp://website/action2
, with param being part of post request, using .htaccess?
No, this isn't possible. A GET and a POST are entirely different requests, with different request headers and different responses. The rewrite engine only affects the URI and can't change the actual request. You're going to have to rely on Javascript on the browser's end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With