- 在项目配置下加入
location /
{
index index.php;
#ThinkPHP REWRITE支持
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
如果按照上面方式,路径中不可以出现 index.php ,否则出错。如果需要加index.php
则如下:
location /
{
index index.php;
#ThinkPHP REWRITE支持
if (!-e $request_filename) {
rewrite ^/index.php/(.*)$ /index.php?s=$1 last;
break;
}
}
- 在 nginx.conf中加入
location ~ \.php$ {
root /Applications/MxSrvs/www;
fastcgi_pass 127.0.0.1:10080;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句
include fastcgi_params;
}