Thanks lot, but still wont to work. And how i set $subdomain to "default" if subdomain doesnt exists? I try this: ~^(www\.)(?<subdomain>[^\.]*)(?<domain>[^\.]*)\.(?<tld>[^\.]*)$ Posted at Nginx Forum: http://forum.nginx.org/read.php?2,237799,237814#msg-237814