I want to redirect all visitors to use https and the non-www. version of my site. I have tried using the following directives which I got from Bootstrap but I get a message telling me there are too many redirects.
# force https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# force non-www
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
I’ve also tried the following with the same result:
There seem to be so many ways to do this! Anyways, my problem seemed to be because the domain is using Cloudflare. I’ve been able to change a setting there to force it through https.