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

Popular posts from this blog

Combining PHP Registration and Login into one class with multiple functions in one PHP file -

Android volley - avoid multiple requests of the same kind to the server? -

magento2 - Magento 2 admin grid add filter to collection -