ssl - Redirecting wildcard subdomains to a different top-level domain with nginx -
we have bunch of wildcard subdomains (_foo.example.com, bar.example.com, etc) that, when accessed via https should redirect equivalent subdomain on our secure domain.
some examples:
- https://foo.example.com => https://foo.secure.com
- https://foo.example.com/some/path => https://bar.secure.com/some/path
- https://bar.example.com => https://bar.secure.com
i think can accomplished nginx rewrites i'm not sure syntax. here's i'm attempting:
server { listen 443; server_name *.example.com; rewrite ^(.*) https://*.secure.com$1 permanent; }
this won't work because i'm not capturing incoming subdomain , using in rewrite.
try (untested):
server { listen 80; listen 443 default ssl; server_name "~^(?<name>\w\d+)\.example\.com$"; rewrite ^(.*) https://$name.secure.com$1 permanent; }
Comments
Post a Comment