server {
listen 80;
server_name *.shop.
com;
charset utf-8;
#access_log off;
access_log /rootlog/nginx/shop.access.log;
location / {
root /www/shop/web;
index index.php index.html index.htm;
#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则
if (!-e $request_filename){
#rewrite /(.*)([^/])$ /index.php?$1$2 permanent;
rewrite ^(.*)$ /index.php?s=/$1 last;
#先前由于顺序原因 会导致重定向次数过多 受index.php的重定向规则影响 一直没生效
#location / {if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s=/$1 last;break;}}
}
}
error_page 404 /404.html;
location = /404.html {
root html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
location ~ \.(js|css|gif|jpg|jpeg|png)$ {
root /www/shop/web;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ \.php(.*)$ {
root /www/shop/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
location /plugin/ {
root /plugin;
}
location /public/ {
root /public;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}