Skip to content
Advertisement

why does .htaccess rewrite behave differently based on form content?

I am doing a post transaction with “having x,” in the form field being submitted. My .htaccess is ensuring https: and www. My redirect is changing the post to a get for the previously mentioned data. If I change pretty much anything it redirects the post just fine.

What I’m looking for is for it to act like test 2, in other words forward as a post transaction with the associated post data. It seems really odd that the content of the form could affect the behavior of the rewriting. Any ideas are very welcome. Thanks!


EDIT: Per the accepted answer below, this was the host running mod-security to guard against sql injection attacks. I could have asked them to turn it off, but decided to leave it and just check $_SERVER[‘REDIRECT-STATUS’] for a ‘403’ in order to respond with an appropriate message.


Here is the code for my test, which I invoke with /test uri to get the form.

JavaScript

And here are the tests, showing the $_POST data and the relevant portions of $_SERVER:

Test 1 having x,

JavaScript

Test 2 havng x,

In test 2 notice the misspelling of having as havng

JavaScript

It will also work with:

JavaScript

But will not work with

JavaScript

Here is the htaccess code:

JavaScript

Advertisement

Answer

Your host is blocking having x. It thinks this is a SQL injection attack on your server. You need to talk to your host if you want them to allow this.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement