Www Redirect loop

Hey there,

I have a problem with my http/https www/non-www redirects. I’m not going to pretend to fully understand all this, but I had no problems when I was on my old server (and also not with Cloudflare yet).
Basically, this is what I have:
DNS:
Two A records, pointing to Cloudflare servers
One CNAME record for www pointing to example.com
SSL:
Flexible by Cloudflare
SERVER:
There is a https force redirect enabled, because that is currently the best way for me to achieve at least that (although my goal is to achieve this off-server)
HTACCESS:

# Turn on RewriteEngine
RewriteEngine on
# Force trailing slash
RewriteCond %{REQUEST_URI} !/(.+)/$
RewriteCond %{REQUEST_URI} !/(go/.+)$
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)$ https://example.com/$1/ [R=301,L]
# Force HTTPS and WWW
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [OR,NC]
#RewriteCond %{HTTP:X-Forwarded-Proto} !https
#RewriteCond %{HTTPS} off  
#RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

The first htaccess block is to make sure all urls have a trailing slash, except filetypes and affiliate links in the form of /go*.
The second block is a leftover from my previous website that did the trick and isn’t working anymore for some reason. It took care of https and non-www urls, which was and stil is my preferred way to go. Back then, I had no extra settings on the server.

My ultimate goal is to be able to redirect all appropriate urls to https and non-www in one step (to avoid two or even three redirects - because why waste time).

However, if I use a www url now (wither with http or https) I get redirect cycling.
If I don’t use www and use http, I first get a 301 redirect to https and then another 301 redirect to a trailing slash in case the original url didn’t have one.

Any ideas as to what I’m missing?

Did you search :search: for too many redirects?

I found this tutorial yesterday, but it’s not clear to me, it only made things more confusing.

For example, point 2)
Always Use HTTPS page rule. What is that? Clicking on the link in the tutorial takes me to a faq page that gives no information about this.

Point 3)
Enable Full or Full (Strict) Mode. Mode of what? I’m not sure what we’re even talking about here.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.