It’s been a while since I’ve touched rewrite rules in htaccess, so I’m going to refer you to the wonderful documentation here that IF provides:
Specifically, this code snippet:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:CF-Visitor} !{"scheme":"https"}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I’ve noticed some slight differences in the code shown and yours. Therefore, I wonder if there isn’t a subtle mistake that you’ve made somewhere.
Try replacing your rewrite code with this code and see if it changes anything.