- Put this in
.htaccess
on NearlyFreeSpeechRewriteCond %{HTTP:X-Forwarded-Proto} =http [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ https://www.ericflin.com/$1 [R=301,L]
- On NearlyFreeSpeech, turn off canonical URLs and turn off force HTTPS. If either is forced on, requests to http://example.com get redirected to https://example.com and then to https://www.example.com, regardless of settings in
.htaccess
.
- On CloudFlare, add the following page rule:💡URL: http://*example.com/* Rule: Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$2)
- Make sure enforce HTTPS is turned on in CloudFlare.
- You don't need any other rules because the
.htaccess
takes care of redirects from https://example.com to https://www.example.com