Map all subdomains to another domain with nginx -
with sever config can redirect requests domain:
server { server_name example.net; listen [::]:80; listen 80; return 301 https://other.net$request_uri; }
but how can redirect subdomains new domain?
www.example.net --> www.other.net webmail.example.net --> webmail.other.net forum.example.net --> forum.other.net
can use placeholder in return command?
use regular expression in server_name
:
server { server_name ~^(?p<subdomain>.+\.)example\.net$ ; listen [::]:80; listen 80; return 301 https://${subdomain}other.net$request_uri; }
please see this answer there few variants on specifying regular expressions in nginx.
Comments
Post a Comment