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

lnmp thinkphp nginx does not support pathinfo solution

WBOY
WBOYOriginal
2016-10-19 10:18:151242browse

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

Statement:
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