Nginx三级域名泛解析,自动对应目录,*.test.xxxxxxxx.com对应/www/test.xxxxxxxx.com/*/目录

###########################三级域名,引用TP重写规则*.test.xxxxxxxx.com###############################

server {
        listen       80;
        server_name  *.test.xxxxxxxx.com;
if ($host ~* ^([^\.]+)\.([^\.]+)\.([^\.]+\.[^\.]+)$) {
        set $mythirddomain $1;
        set $mysubdomain $2;
        set $mydomain $3;
    } 
index index.html index.htm index.php;
root /www/test.xxxxxxxx.com/$mythirddomain;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
#thinkphp伪静态规则
location / { 
    if (!-e $request_filename) { 
        rewrite  ^(.*)$  /index.php?s=$1  last; 
        break;   
    } 

}


}