Nginx Low version does not support PathInfo mode, thinkphp solution for this problem

Source: Internet
Author: User

Move a thinkphp project from Apache to nginx1.2, Zennai, nginx This version does not support PathInfo mode by default

First, edit Nginx's virtual host configuration file

    Location ~. *. (PHP|PHP5)? $        {                #原有代码        }
If (-e $request _filename) { 
Rewrite ^ (. *)$ /index. PHP? s=last ;
break;
}

#去掉 $ is to match the end of the line, that is, it can be matched. php/to achieve PathInfo #如果你不需要用到php5后缀, you can also remove the location~. php {#原有代码 #定义变量 $path _info for storing pathinfo information Set$path _info""; #定义变量 $real _script_name, for storing real addressesSet$real _script_name $fastcgi _script_name; #如果地址与引号内的正则表达式匹配if($fastcgi _script_name ~"^ (. +?\.php) (/.+) $") {#将文件地址赋值给变量 $real _script_nameSet$real _script_name $1; #将文件地址后的参数赋值给变量 $path _infoSet$path _info $2; } #配置fastcgi的一些参数 fastcgi_param script_filename $document _root$real_script_name; Fastcgi_param script_name $real _script_name; Fastcgi_param path_info $path _info; }

The above is on the Internet to find the answer, in fact, just add this paragraph can be

if (-e $request _filename) {   rewrite  ^ (. *) $  /index.php?s=$1last  ;     Break ;    }

Reference http://doc.thinkphp.cn/manual/hidden_index.html

Nginx Low version does not support PathInfo mode, thinkphp solution for this problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.