subdomain redirecting

I’ve got 2 subdomains: and

The first works well while the second redirects to

I can’t understand what is happening

On the other hand, I have 2 these two rules in htaccess. If I remove them, the second subdomain works well, but I need these two rules:

#First rewrite any request to the wrong domain to use the correct one (here www.)

RewriteCond %{HTTP_HOST} !^www\.

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

#Now, rewrite to HTTPS:

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The first one should be redirected as well if it’s affected by that htaccess. Is it?