server {
    listen       80;
    server_name  *.domain.name;
    if ( $host ~* .(.*)\.(.*)\.(.*))
    {
    set $site_dir $1;
    }
    location / {
        root   /www/$site_dir;
        index  index.html index.php;
    }
    location ~ ^.+\.php {
        root           /www/$site_dir;
        fastcgi_pass   bakend;
        fastcgi_index  index.php;
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
        include        fastcgi.conf;
    }
}