Apache mod_rewrite redirect for non secure requests to secure www. subdomain
Wednesday, October 29th, 2008In many cases SSL certificates are issued for the "www." domain.
Then you'll want to have all links pointing to "www." domain otherwise you'll see Firefox's error message:
"Secure Connection Failed. The certificate is only valid for www.domain.com"
[code]
RewriteEngine on
#RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule .* https://www.domain.com%{REQUEST_URI} [QSA,R=301,L]
[/code]
