Htaccess Problem With HTTP Form Posts

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 %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*)$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 instead of This way, posts will not be redirected by the htaccess code.

Similar Posts:

Alvin Poh lives in Singapore, and is interested in marketing, techy stuff, and likes to just figure out how the two can work with each other. He can also be found on Google+.

Leave a reply:

Your email address will not be published.


Sliding Sidebar