This is a follow-up to a question I asked last year about setting up mod-rewrites: http://bit.ly/h8PVd9
I have the following mod-rewrite on my server which forces all traffic to use the full URL (for the sake of this question, I’ll use http://www.mysite.com). It’s working fine and there are no issues:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteCond %{HTTP_HOST} !^dev\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
So that’s all well and good, however I need to add an SSL to the server, covering the domain http://www.mysite.com. What (if any) modification/exception do I need to add to my pre-existing rewrite code to ensure any calls to https://www.mysite.com won’t be redirected to http://www.mysite.com? Do I need to revise anything at all?
After testing and consulting with my webhost, the answer to this question is the following:
The first rule addresses all https requests to the server and allows them through without getting redirected by my original rules. The second is a re-write of my original rules, and addresses the forced use of http://www.mysite.com regardless of what the user types in.
@Paul – you were pretty close on this one, but with my existing re-writes this solution solves both issues.