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://example.com
and properly redirects to https://www.example.com
but when the incoming URL is https://example.com
it will not forward to https://www.example.com
- Any suggestions?
EDIT: it should also send http://www.example.com
to https://www.example.com
.
RewriteCond %{REMOTE_ADDR} !127\.0\.0\.0
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^www.example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]