If you see # SERVER-HTTPS-ON # (on), add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=on [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # SERVER-HTTPS-ON # (1), add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=1 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # SERVERPORT443 # add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{SERVER_PORT} !443 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # LOADBALANCER #, add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # CDN # add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP:X-Forwarded-SSL} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # Cloudflare # add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"' RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
If you see # ENVHTTPS # add
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{ENV:HTTPS} !=on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>
At the bottom of the ssl test page you will see HTTP HOST. This should be the same as your domain. If not, you may need to tightly configure the domain to prevent redirection problems, for example:
RewriteEngine on RewriteCond %{HTTPS} !=on [NC] RewriteRule ^(.*)$ full_url_with_https/$1 [R=301,L]
more details here