Home > Backend Development > PHP Tutorial > thinkpad win7 oem allows Nginx to support ThinkPHP URL rewriting and PATHINFO method sharing

thinkpad win7 oem allows Nginx to support ThinkPHP URL rewriting and PATHINFO method sharing

WBOY
Release: 2016-07-29 08:46:27
Original
1194 people have browsed it

I searched a lot of methods on the Internet but didn't work. After a day of research, I found that the situation of 'URL_MODEL' => 2 can be perfectly supported through the following configuration

Copy the code The code is as follows:


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 $1;
set $path_info $2;
}
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_para m SCRIPT_FILENAME $document_root/$ script;
fastcgi_param SCRIPT_NAME $script;
}


Here, all requests under the project are forwarded to index.php for processing, which is the single entry file of ThinkPHP; then the request for the php file is handed over to fastcgi for processing. And add support for PATH_INFO.
After restarting Nginx, URLs such as http://localhost/project/Index/insert and http://localhost/project/index.php/Index/delete can be accessed correctly.
Another thing to note is that there must be a space between if and the following brackets in the Nginx configuration file, otherwise an unknown directive error will be reported.

The above has introduced the method sharing of thinkpad win7 oem to enable Nginx to support ThinkPHP URL rewriting and PATHINFO, including the content of thinkpad win7 oem. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template