Redirect http/s to www having random redirect errors


#1

I switched to https about 2 weeks ago. Initially everything went well. But redirect errors keep popping up and I just can’t find out why?!

Firstly the SSL is with CF. It’s working.

I enabled Always use HTTPS.

I have a page rule caching all for 4 hours.

My domain should be https://www.example.com

I have a sub domain https://one.example.com

The problem:
People are telling me they are getting occasional “this page isn’t redirecting properly” error on https://www.example.com
I’ve seen it happen randomly. I’ve cleared the cache and it’s working again.

This morning on mobile I tried https://www.example.com/sample.html and there was a “this page isn’t redirecting properly” error.

I then typed in http://example.com/sample.html and it redirected to https://example.com/sample.html I don’t understand why it did not redirect to https://www.example.com/sample.html

Google analytics then sent me a message saying they are getting hits from different versions of my site https://www.example.com https://example.com etc

If I enter in http://www.example.com or http://example.com into any desktop browser it resolves nicely into https://www.example.com. But on this mobile browser it’s not …

Further, on Cloudflare analytics I’m getting 11% of “empty”.

My Htaccess (I thought cloudflare “always use https” bypassed this) before switching to https was this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

My Htaccess after switching to https is this

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

I’m really bashing my head on this one. Any insight on how to solve this would be greatly appreciated!


UPDATE

I’m now trying a page rule with https://example.com/* >forward 301 > https://www.example.com/$1 ) it seems to be working but I don’t know if this is the best option.


#2

Hi there,

Have you solved the problem?


#3

Yep, this is what fixed it.


#4

I have the same problem which has a huge impact for users. This is unacceptable. I disabled cloudflare. Trying to solve the problem.


#5

Did you try this?


#6

I’m using https only for a subdomain, so i can’t try putting “www” in the beginning of subdomain.
It randomly stucks in a redirect loop, furthermore, i’m using cloudflare only for firewall and cdn. I already have https issued for that subdomain and already set it up on cpanel.