Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

redirect some subdomains to https using server_name regex

$
0
0
Hi

I'm trying for a while now and I've searched google, but I can't seem to find the right solution for my redirect problem.

I have a webserver running nginx, and I'm trying to get all subdomains linked tot this mailserver to redirect to https automatically.

the subdomains are
- mail
- mailserver
- webmail
- connect

I allready setup the correct multidomain certificate so that's handled. I have tried many server_name regexes but none of them work.

server_name ~^(mailserver|mail|connect|autodiscover|webmail)\.mydomainname\.com$;
rewrite ^ https://$server_name$request_uri? permanent;

But when I save this and try one of the above subomains, I just get this full server_name back in my browser address...

I am forgetting something or doing something wrong, but what? Please help...

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>