How to do a redirect to https only the main domain and subdomains to leave http?

Tell me, how to write redirect main domain to https://, leaving the sub-domains at http://

For example, to www.mysite.ru opened on https://www.mysite.ru, and sub.mysite.ru - http: //sub.mysite.ru.
Subdomains a lot.

rewrite ^/(.*)$ https://www.m-instrument.ru/$1 permanent; redirects all to www,
how to separate the main domain from the subdomain to nginx realized. what subdomain it is necessary to return to http?
June 27th 19 at 15:36
2 answers
June 27th 19 at 15:38
something like that
RewriteCond %{HTTP} On
RewriteCond %{HTTP_HOST} ^(www\.|)mysyte\.ru$ [NC]
RewriteRule ^(.*)$ htts://mysyte.EN/$1 [R=301,L]
I have nginx - Carolina15 commented on June 27th 19 at 15:41
June 27th 19 at 15:40
Create a redirect to https for domain.ru and www.domain.ru:
server {
 listen 80;
 listen [::]:80;
 server_name domain.ru www.domain.ru;
 location / {
 return 301 https://domain.ru$request_uri;
}
}

If the subdomains are switching to https, then check
Strict-Transport-Security: max-age=31536000; includeSubDomains

If there is such a line, remove includeSubDomains.
and if it is not? you need to add? - Carolina15 commented on June 27th 19 at 15:43
: If You're talking about Strict-Transport-Security, this line tells the browser to go only via https. The rule is valid for the time specified in max-age. This line is optional. - Carolina15 commented on June 27th 19 at 15:46

Find more questions by tags Nginx