解决 nginx 服务器下使用 thinkphp 框架不支持 pathinfo 的问题。
更改 php.ini
找到:
cgi.fix_pathinfo=0
改为:
cgi.fix_pathinfo=1
修改 nginx 对应配置文件,在 server 段加上
location / { index index.php; #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; } try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock;#这个是监听的套接字,记得改成自己的 fastcgi_index index.php; include fastcgi.conf; fastcgi_param script_FILENAME $document_root$script; fastcgi_param script_NAME $script; fastcgi_param PATH_INFO $path_info; }
修改完后,记得重启nginx服务器 service nginx restart 。