Skip to Content Skip to Menu

.htaccess 301 redirect clearing get and post variables

Just an issue I have come across recently on my website, so I thought I could share my problem and the resolution.


Member's login was not working after I added the following .htaccess lines of code to redirect non-www address to www address:

RewriteEngine On
Options +FollowSymLinks
RewriteBase /

RewriteCond %{http_host} ^ [nc]
RewriteRule ^(.*)$$1 [R=301,nc]

This was put in place for better performance in search engines by having only one version of the same page.

My server name defaults to the non-www address which when the redirect runs while trying to login, the POST variables are cleared completely. Therefore the users are unable to login because there was apparently no form data sent.


Rather than letting the redirect actually occurring, I made the form action go to the absolute path of the www address.