Home > php教程 > php手册 > lnmp thinkphp nginx does not support pathinfo solution

lnmp thinkphp nginx does not support pathinfo solution

WBOY
Release: 2016-10-19 10:18:15
Original
1288 people have browsed it

lnmp thinkphp nginx does not support pathinfo solution
The first one: the official method of lnmp one-click installation package.

Reprinted at http://www.aiyuanxing.cn/index.php/category/nginx
Change php.ini
Found: cgi.fix_pathinfo=0
Change to: cgi.fix_pathinfo=1
Modify nginx corresponding configuration file
Remove the # in include pathinfo and add # before try_files;

I tested this method and it didn't work for me.

Second type: I can support thinkphp's pathinfo mode in lnmp1.1 and lnmp1.2.

location / {
#ThinkPHP Rewrite
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ .php($|/){
#Configure PHP to support PATH_INFO for URL rewriting
set $script $uri;
set $path_info “”;
if ($uri ~ “^(.+?.php)(/.+)$”) {
set $script $1;
set $path_info $2;
}
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}

After modification, remember to restart the nginx server service nginx restart

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template