v1.2.11b: Initial POST request transforms into GET

Topics: User Forum
Apr 19, 2007 at 3:25 PM

I'm having problems redirecting a user (with some post variables) from a specific url to the root of the website.

IterationLimit 0
RewriteRule ^/subfolder/(.*) /$1 [R=301,L]
This is the complete configuration.

This works perfect when the user is using a GET request. However, when the user is using a POST request it all goes wrong.

I've looked at the headers in the browser.
POST /subfolder/formpost.aspx HTTP/1.1
HTTP/1.x 301
Location: http://www.domain.com:80/formpost.aspx
//redirect goes here. And then it goes wrong:
GET /formpost.aspx HTTP/1.1
Am I doing something completely wrong here, or is what I want not possible?

Apr 23, 2007 at 11:57 AM
Edited Apr 23, 2007 at 3:02 PM
I've been trying a lot of things, but I'm still getting the above problem.

Does anyone have a tip (or even better the solution :) ) ?

Well, I've just found out it isn't possible. This is ofcourse logical, but I was hoping for some tips.
Apr 25, 2007 at 5:05 PM
Hmm, yes, I think that IIRF always transforms to GET.
That seems like something we ought to change.
Apr 25, 2007 at 7:04 PM
Well, according to recent information this behavior is pretty much normal.
However, if you can build this (as a on of a kind option) in IIRF that would be awesome.
May 3, 2007 at 8:30 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 10, 2009 at 6:41 AM

I'm bumping into exactly the same thing, when I attempt to redirect a POST, it turns into a GET and the POST'd data is lost.  My preference would be to have a way to ignore/avoid redirecting POST methods entirely, only redirecting GETs, would something like that be possdible?

When I first bumped into this I saw the open work item but it has since been closed, so I'd like to re-request this feature.

For the bigger picture of what I'm doing, I previously had WordPress installed in a variety of paths depending on the site, some sites were /index.php, some were /wp/index.php or /wordpress/index.php or a small set of others, so I have a few R=301 rules that redirect the browser to the correct URL, followed by a rewrite rule that prepends a /wordpress/index.php/ to the URL internally so that IIS/PHP/WordPress manage to work.

The problem is that some WordPress plugins construct their forms to POST based on the URL they see in the request rather then creating the destination using WordPress' configured permalink structure.

If I turn off my various R=301 rewrite rules then the forms work correctly, but users see uglier URLs in some cases, so my goal would be to redirect any GET request but skip the redirects for a POST.


Sep 10, 2009 at 7:04 PM

I re-opened the request.

Sep 11, 2009 at 11:26 AM

So I presume that this would be why my form is failing when it's using Request.Form in the mail script?

Form header is <form action="/mail" method="post" name="form1" id="form1"> with /mail rewriting to another location in the .ini file.

I would be interested to see a work around for this without having to amend the mail script page.


Sep 11, 2009 at 12:44 PM

Yes it might be why.  You can insert a rule into the .ini file to NOT rewrite POSTS for the mail form.  If you do this, you'll probably want to match on the incoming URL for that form "/mail"  of whatever.  Insert a rule that matches that URL and does nothing.

RewriteRule ^/mail$   -   [L]