If you want to redirect domainname.com and www.domainname.com to https://www.domainname.com, please use below codes in .htaccess file of the domain:
RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) https://www.domainname.com /$1 [R,L]
If you want to redirect domainname.com and www.domainname.com to https://www.domainname.com, please use below codes in .htaccess file of the domain:
RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) https://www.domainname.com /$1 [R,L]