Redirecting after POST processing

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
dcleal
New Member
New Member
Posts: 9
Joined: Sat Apr 07, 2007 5:10 pm

Redirecting after POST processing

Post by dcleal »

Hi,

running CMSMadeSimple 1.11.9, I'm having trouble grasping what happens to POST requests.

The site has the multidomain module and - as far as I can tell from other posts - the standard rewrite rules turned on, and this all seems to be working perfectly. When a POST request comes in for a given URL, it get rewritten OK, and in fact the template gets rendered and embedded user tags get executed (these tags generate an email that does get sent). However, what gets returned to the client browser is not 200 status and the result of all that work, but instead a 301 redirect to the same URL, that causes the browser to execute a GET.

The reason I care about this is that the processing of the POST request takes advantage of the POST variables to not only send an email, but to generate a page that says something like "thanks for the input", and this is now getting lost.

Is there any way to control this redirecting behaviour? I'd rather not rewrite the whole thing using a Form building plugin or something as, apart from this detail, it all works perfectly.

Regards

- Dave
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Redirecting after POST processing

Post by velden »

Are you sure the POST 'request' (parameters) really makes it to your template? Do you use some POST parameters to send the email so you can actually verify this?

It sounds like me that a rewrite_rule initiates the http 301 which would mean that indeed the browser makes a new GET request and POST parameters get lost. In that case the POST request will never be processed by CMSMS because the rewrite_rule is handled before php scripts etc.
dcleal
New Member
New Member
Posts: 9
Joined: Sat Apr 07, 2007 5:10 pm

Re: Redirecting after POST processing

Post by dcleal »

POST parameter values definitely make it to the script: they are correctly echoed into the email.

Below are the rules from the .htaccess file. You'll see that POSTs are explicitly excluded from the only 301 rule, so I think something else is going on,


# Rules required by the multi-domain module
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [NE,R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Redirecting after POST processing

Post by velden »

Then I expect something in your UDT or template to initiate that redirect.

I'am not aware of CMSMS automatically redirecting front end requests.
Post Reply

Return to “The Lounge”