Http://www.thinkphp.cn/topic/3138.html
Open the Nginx profile/usr/local/nginx/conf/nginx.conf is generally in this path, depending on your installation path may vary. If you configure Vhost, and you only need one of your vhost support PathInfo, you can open your Vhost configuration file directly. Find a code similar to the following (different versions of Nginx may be slightly different, but not very far apart)
Location ~. *. (PHP|PHP5)? $
{
#原有代码
}
Modify to the following code:
#去掉 $ is to not match the end of the line, that is, it can match. php/to achieve the PathInfo
#如果你不需要用到php5后缀 or remove it
location ~. php
{
#原有代码
#定义变量 $ Path_info, for storing pathinfo information
set $path _info "";
#定义变量 $real _script_name for storing the real address
set $real _script_name $fastcgi _script_name;
#如果地址与引号内的正则表达式匹配
if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") {
#将文件地址赋值给变量 $real _script_name
Set $real _script_name $;
#将文件地址后的参数赋值给变量 $path _info
set $path _info $
}
#配置fastcgi的一些参数
fastcgi_param script_filename $document _root$real_script_name;
Fastcgi_param script_name $real _script_name;
Fastcgi_param path_info $path _info;
}
In this way, the Nginx server can support PathInfo. However, you also need to configure the rewrite rule if you want to support the thinkphp Url_mode set to 2 mode. Locate the Access_log statement, and add the following statement above it:
#如果请求既不是一个文件, and not a directory, execute the rewrite rule
if (!-e $request _filename)
{
#地址作为将参数rewrite到index. php.
rewrite ^/(. *) $/index.php/$1;
#若是子目录则使用下面这句, change the subdir to the directory name.
#rewrite ^/subdir/(. *) $/subdir/index.php/$1;
}
Finally, save the configuration file, restart the Nginx service, the thinkphp Url_model set to 2, visit your page, if the normal access, congratulations to your pathinfo configuration succeeded ^_^