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

Re: redirect some subdomains to https using server_name regex

$
0
0
Never mind... most of the times, right after you post something to a forum, you will find the answer all of a sudden..

but, to be polite, I will also include the solution (if a better one exists, please correct me)

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

The ?<sub> part wil catch the requested subdomain in the list and put it in the $sub variable. Then use this to make the redirect... A couple of hours lost with this one....

Viewing all articles
Browse latest Browse all 4759

Trending Articles



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