[转分享]nginx配置ThinkPHPRewrite
server {
listen 88;
server_name www.test.com;
root /www/web/www.test.com;
index index.php;
#过滤文件访问权限
location ~ ^/(admin|api).php$ {
deny all;
}
location / {
#ThinkPHP Rewrite
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ .php($|/){
#配置PHP支持PATH_INFO进行URL重写
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+?.php)(/.+)$") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1d;
}
location ~ .*.(js|css)?$ {
expires 12h;
}
}