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.
Similar Posts:
- Edit .htaccess to increase PHP’s max file upload
- How To Dynamically Insert Affiliate Links or Track Referrals With Aweber
- How To Integrate Your Custom Bit.ly API With Tweet This Plugin
- How To Solve Problem of PHP Fatal error: Allowed memory size of 8388608 bytes exhausted…
- Simple Way to Relay or Pass POST Data From A Page to Another Without .htaccess, Even Cross-Domain









Mon, Dec 22, 2008
Programming & Code