Help with the regular season for nginx

0 like 0 dislike
5 views
There is config, like

server { listen 80; server_name ~^(?:www\\.)?(?P.+)$; server_name_in_redirect off; resolver 127.0.0.1; 

Suitability in variable $host_wo_www gets the full domain name without www, but I need to get another variable, that gets there just the subdomain of the third level, that is, have www.subdomain.domain.com I need to have a variable where you will get only a subdomain, can anyone help with the regular season?
by | 5 views

1 Answer

0 like 0 dislike
I have just happened:
server_name ~^(?:www\\.)?(?P.+)?\\.(?P[^\\.]+\\.[^\\.]+)$;
If the domain is more than 3 parts, the "excess" go to the subdomain:
abc.def.ghi.ru ->abc.def + ghi.ru
by

Related questions

110,608 questions
257,186 answers
0 comments
28,662 users