Force SSL and WWW in .htaccess
- by Stephen
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]