Introduction: This is a detailed page for nginx to support thinkphp URL rewriting and pathinfo. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 343152 'rolling = 'no'>
Thinkphp supports providing friendly URLs through pathinfo and URL rewrite. You only need to set 'url _ model' => 2 in the configuration file. In Apache, you only need to enable the mod_rewrite module for normal access, but pathinfo is not supported by nginx by default, so we need to modify the nginx. conf file.
I searched the internet for a lot of methods that didn't work. After studying for a day, I found that the following configuration can perfectly support 'url _ model' => 2.
1 Location/project /{
2 Index index. php;
3 if (! -E $ request_filename ){
4 rewrite ^/project/(. *) $/project/index. php/$1 last;
5 break;
6}
7}
8
9 location ~ . + \. Php ($ | /){
10 set $ script $ URI;
11 set $ path_info "/";
12 if ($ URI ~ "^ (. + \. Php) (/. + )"){
13 set $ script $1;
14 set $ path_info $2;
15}
16
17 fastcgi_pass 127.0.0.1: 9000;
18 fastcgi_index. php? If_rewrite = 1;
19 include/apmserv/nginx/CONF/fastcgi_params;
20 fastcgi_param path_info $ path_info;
21 fastcgi_param script_filename $ document_root/$ script;
22 fastcgi_param script_name $ script;
23}
In this example, all requests under the project are forwarded to the index. PHP to process, that is, the single portal file of thinkphp. Then, the request for the PHP file is sent to FastCGI for processing, and the support for path_info is added.
After nginx is restarted, URLs such as http: // localhost/project/index/insert, http: // localhost/project/index. php/index/delete can be accessed correctly.
Note that there must be a space between the IF and the parentheses in the nginx configuration file. Otherwise, the unknown ctictive error will be reported.
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/343152.html pageno: 5.