I have successfully installed a URL Rewrite policy, which I have included below (.htaccess):
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^rest/([\w\d~%.:_\/-]+)$ controllers/rest_api.php?params=$1&v=t [NC]
However, it is losing the POST data. I have seen other questions solve this by changing the FULL url to a relative one (which mine is), or by installing something like MOD_PROXY. However, I would like to keep this without the need to install additional apache mods if possible. Ive also tried [NC,L] too.
Any ideas? The Rewrite is functioning, but I'm just losing the POST data. It is, however, keeping POST as the request_method. It is also keeping the headers, as it passes the authentication block of the API I am building.
You probably need 2 rewrite conditions to stop rewriting for valid files and directories.
There is no special setting actually to make POST working. Just create a .htaccess in DocumentRoot as this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^rest/([\w\d~%.:/-]+)$ info.php?params=$1&v=t [L,QSA]
Then create info.php in DocumentRoot as:
<?php phpinfo(); ?>
And finally create a form named form.html like this under DocumentRoot:
<html><body>
<form method="post" action="/rest/queue/submit.xml?locations=this%20is%20a%20test">
<input type="text" name="foo" value="foo"><br />
<input type="text" name="bar" value="bar"><br />
<input type="text" name="baz" value="baz"><br />
<input type="submit" name="go" value="Submit">
</form>
</body></html>
Finally open localhost/form.html in the browser and click on submit. It will open localhost/info.php and should show your POST data intact.
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