tags:

views:

23

answers:

1

Hi,

During development, I used subdomain.domain.com and everything worked. Moving to live, the files are under www, but I wanted to use domain.com, and that's making certain functionalities not work as follows.

I got a dedicated SSL certificate for domain.com, so I have this in my htaccess, and my SSL works fine:

# Redirect www.domain.com to domain.com

RewriteCond %{HTTP_HOST} ^www.domain.com [NC]

RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

However for some reason that breaks some other functionality where a form gets reposted and I can't figure out why. But if I change htaccess to this:

# Redirect domain.com to www.domain.com

RewriteCond %{HTTP_HOST} ^domain.com [NC]

RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

then the broken functionality works, but the SSL doesn't.

Before I go invest in an SSL for www.domain.com, I wanted to check with the experts here to see if there is something simple I can do to my htaccess file to make both scenarios work.

Many thanks in advance!

+2  A: 

A visible 301 redirect is losing its POST data. From RFC 2616:

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

So, you have to fix the forms, not the .htaccess.

toscho