You should make your https implementation as a first rule of your .htaccess file, could you please try following. Written as per your shown samples, please make sure you clear your cache before testing your URLs.
RewriteEngine ON
##Rule for applying https to non-http calls.
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
##Look for if any page doesn't have `/`slashes at the end then add it.
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ $1/ [R=301,L]
##Rules for non exiting file or directory to main.cgi file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ main.cgi [L]
NOTE: Using RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
personally gives me 1 slash at end so I had written a separate rule for adding trailing /
for this one, to avoid 2 times /
at the end of url.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…