Force SSL and WWW in .htaccess

Posted by Stephen on Pro Webmasters See other posts from Pro Webmasters or by Stephen
Published on 2011-02-07T18:37:54Z Indexed on 2011/02/07 23:34 UTC
Read the original article Hit count: 399

I'm looking for a way to force SSL and WWW.

I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a url in this format: "http://domain.com" and properly redirects to "https://www.domain.com" but when the incoming url is "https://domain.com" it will not forward to "https://www.domain.com" -- Any suggestions?

EDIT: it should also send "http://www.domain.com" to ""https://www.domain.com"

RewriteCond %{REMOTE_ADDR} !127\.0\.0\.0
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^www.domain\.com$
RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]

© Pro Webmasters or respective owner

Related posts about apache

Related posts about htaccess