I have changed hole webstore to https. So I want to rewrite all domains except mobile subdomain (http://m.my-store.com) to https://www.my-store.com
#First rewrite any request to the wrong domain to use the correct one (here www.)
#mobile subdomain shouldn't rewrite
RewriteCond %{HTTP_HOST} !m\.
RewriteCond %{HTTP_HOST} !^www\.my-store\.com$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.my-store\.com$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Result:
http://my-store.com OK (correct rewrite to https://www.my-store.com)
http://www.my-store.com OK (correct rewrite to https://www.my-store.com)
https://my-store.com X (stays with https://my-store.com)
https://www.my-store.com OK (correct rewrite to https://www.my-store.com)
http://m.my-store.com OK (correct rewrite to https://www.my-store.com)