I like to handle different sub domains in my Nginx server, this is my config file (partially)
server {
listen 80 default_server;
listen 443 default_server ssl;
include ssl/mysite.conf;
server_name default_server;
rewrite ^(.*)$ https://mysite.com$1 permanent;
As you can see all the requests to sub-domain.mysite.com/query are redirected to mysite.com/query always in https. I will like to execute that rewrite only if the sub-domain is different from string1 and string2. So:
string1.mysite.com/query ---> https://string1.mysite.com/query
foo.mysite.com/query ---> https://mysite.com/query