I've found quite examples but all of them for an especific domain, and my server has many main domains and subdomains.
I want all main domains to be rewrite to https://www but the subdomains to https:// only:
main-domain.xxx -> https://www.main-domain.xxx
sub.main-domain.xxx -> https://sub.main-domain.xxx
I'm using now this rules to get https://
RewriteCond %{REQUEST_SCHEME} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]