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
Redirecting after POST processing
Re: Redirecting after POST processing
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.
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.
Re: Redirecting after POST processing
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]
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]
Re: Redirecting after POST processing
Then I expect something in your UDT or template to initiate that redirect.
I'am not aware of CMSMS automatically redirecting front end requests.
I'am not aware of CMSMS automatically redirecting front end requests.