Help with the regular season for nginx

0 like 0 dislike
There is config, like

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

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 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 +

Related questions

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