.htaccess redirect from http to https and from non-www to www redirect – Make site permanently SSL secured

put this in your htaccess file:

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