Sub-domain in variable

huttarichard nginx-forum at
Tue Mar 26 12:56:28 UTC 2013

Hi guys,

I have question. My server_name looks like this:

server_name  ~^(www\.)(?<domain>[^\.]*)\.(?<tld>[^\.]*)$;

but I need, for my website do subdomains. I try:

server_name  ~^(www\.)?(?<subdomain>\.)(?<domain>[^\.]*)\.(?<tld>[^\.]*)$;

but won't work for me. And what will be super, if subdomain  emtpy se to
default (mean string "default").

Can me anybody help?

Posted at Nginx Forum:,237799,237799#msg-237799

More information about the nginx mailing list