nginx配置thinkphp的pathinfo模式 之前介绍过一篇:Nginx不支持ThinkPHP配置pathinfo问题的解决方法 ,大家作下比较,争取最快的解决问题。
例子:
复制代码代码示例:
server {
(责任编辑:IT)listen 88; server_name www.it.net.cn; root /www/web/wwwitnetcn; 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;//如果采用的是php-fpm模式,fastcgi_pass unix:/tmp/php-cgi.sock; 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; } } |