我们将*.example.com泛域名解析到/home/wwwroot的目录下,比如test.example.com解析到目录/home/wwwroot/test下
配置如下:
server {
listen 80;
server_name ~^(?<subdomain>.+).example.com$;
index index.html index.htm index.php;
root /home/wwwroot/$subdomain/;
location ~ .php$ {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 7d;
}
}
网友回复