I try to run the whole site through https and force www.
I saw a number of solutions that provide forcing both www and https, and even several in combination, but I canβt get it to work. I usually end up in a redirect cycle.
The closest I have is the following, but it's still not close enough:
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
I need https://www.example.com/
http://example.com SUCCESS
https://example.com SUCCESS
http://www.example.com FAIL
https://www.example.com SUCCESS , although there is no actual redirect.
thanks
Update
The following code successfully performs the redirect that I need:
RewriteCond %{ENV:HTTPS} !on [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] RewriteCond %{ENV:HTTPS} on [NC] RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
source share