December 22

Htaccess Problem With HTTP Form Posts

0  comments

I had problems with my HTTP form posts working properly after implementing a htaccess script. The htaccess script basically redirects the non-www version of my website to the www version.

However this caused problems with HTML form postings that posted to the non-www version, as the form postings would just go missing – as if a blank form was posted.

The solution? Exclude form posts from the redirect:

RewriteCond %{REQUEST_METHOD} !^POST$
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

This is inefficient though, and if I wasn’t using an off-the-shelf application, I would code my forms and scripts to not POST to the non-www version of my domain. For example, forms should all post to www.example.com instead of example.com. This way, posts will not be redirected by the htaccess code.


Other posts about scaling up businesses

How To Choose Digital Marketing Channels (A Powerful 6 Step Process)

I Only Own One Pair Of Shoes

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
free playbook

Get Your Free 5E Playbook

My 5E playbook is now available for a limited time!

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"62516":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"62516":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]}}]}__CONFIG_colors_palette__
Get Your Playbook