使用htaccess [duplicate]同时从(.html到.php)和(http到https)和(非www到www)重定向

This question already has an answer here:

I am currently editing an existing site to enable https in it. The website has three requirements for redirect

urls with .html to .php
http to https
non-www to www

The code I am currently using is this

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

But when I check www.websitename.com, it is not being redirected to https://www.websitename.com

I am trying many combinations for days (I have only basic knowledge of regexp), but it is showing one deficiency or another. Any help will be appreciated

</div>

To redirect to https you can use:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]