I need a Guru\'s advice.
On Nginx\'s conf file, I would like to get the subdomain as a variable in order to redirect accesses as follow.
conf
You can use a regular expression in the server_name to extract the part you need as a named capture. For example:
server_name
server { listen 80; server_name ~^(?<name>.+)\.example\.com$; return 301 http://example.com/$name$request_uri; }
See this document for more.