nginx - How redirect dynamic subdomain to a domain with uri -


i have scenario. want redirect in nginx subdomains in format.

(profile_name).mydomain.com mydomain.com/profile/(profile_name)

how can in nginx?

thanks.

you use regular expression server block.

server {     server_name ~^(?<name>.+)\.example\.com$;     return 301 http://example.com/profile/$name$request_uri; } 

see this document details.


Comments