Configuring Nginx support for thinkphp URL rewriting and PathInfo
Thinkphp supports the use of pathinfo and URL rewrite to provide a friendly URL, just set the ' Url_model ' + 2 in the configuration file. Under Apache only need to open the Mod_rewrite module can be normal access, but Nginx is not supported by default PathInfo, so we need to modify the nginx.conf file.
Search on the Internet a lot of methods do not work, the study of the day, found through the following configuration can be perfectly supported ' Url_model ' and 2 of the case of the location/project/{
? index index.php;?
? if (!-e $request _filename) {?
? rewrite ^/project/(. *) $/project/index.php/$1 last;?
? break;?
?}?
?}?
??
Location ~. +\.php ($|/) {?
? set $script $uri;?
? set $path _info "/";?
? if ($uri ~ "^ (. +\.php) (/.+)") {?
? set $script $;?
? set $path _info;?
?}?
??
? fastcgi_pass 127.0.0.1:9000;?
? fastcgi_index index.php? if_rewrite=1;?
? include/apmserv/nginx/conf/fastcgi_params;?
? fastcgi_param path_info $path _info;?
? fastcgi_param script_filename $document _root/$script;?
? fastcgi_param script_name $script;?
?}
Here, the requests under Project are forwarded to index.php for processing, that is, the single entry file for thinkphp, and then the request to the PHP file is given to fastcgi for processing, and the support for Path_info is added.
After restarting Nginx, Http://localhost/project/Index/insert, http://localhost/project/index.php/Index/delete such URLs can be correctly accessed.
One more place to note is that there is a space between the if and the parentheses in the Nginx configuration file, otherwise the unknown directive error will be reported. It's been a long time since I was transferred.
?
1/F wpeng1123 2011-04-10
My project file is test thinkphp put under test I change this after the access to the login page, it jumps to index.php/public/login but a system error occurred
The system has an error
You can choose [Retry] [back] or [go home]
[Error message]
Unable to load module public
Solving
2/F Jocson 2011-11-22
Same ....
3/F Mengdejun 2011-11-22
The path is not configured correctly.