ubuntu+ngnix+thinkphp pathinfo配置
一、thinkphp 项目改为pathinfo模式
XXX/ThinkPHP/Conf/convention.php文件中找到
'URL_MODEL' => 1, // URL访问模式,可选参数0、1、2、3,代表以下四种模式:
// 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE 模式); 3 (兼容模式) 默认为PATHINFO 模式
默认值为1,可不改
二、配置ngnix
server{
listen 80;
server_name vote.nhwa-hexin.com;
root /var/www/html/vote;
index index.php index.html index.htm;
location /{
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ ^(.+\.php)(.*) {
fastcgi_pass unix:/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$"){
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}