Landing page redirect

We’ve been facing landing page redirect if we request our site using ‘http’ protocol, site first redirect to ‘http://www.mysite.com’ then to ‘https://mysite.com’ which we want.
Check this screenshot: https://prnt.sc/ppn9ui

While we request the site using ‘https’, it’s fine and there’s no redirect to ‘www’ and site goes to ‘https://mysite.com’ directly.

We tried redirection with below code, it didnt work, right now we are using SGoptimizer to handle the redirect.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

[edited by staff]

Let us know if there’s anything you need or we need to do.