The problem of using Thinkphp's PathInfo mode under Nginx server

Source: Internet
Author: User
Tags rtrim nginx server
LNMP after installing the package on one click, it is found that thinkphp's PathInfo mode is not available.
Baidu, found nginx/conf/vhost/domain name file has opened PathInfo instructions, so started the pathinfo.
But the project still didn't work, so I ran the code on both the local and the server:


    
     var_dump($_SERVER);

Find Php_self This one is different, so the problem may be here.
Next, search for php_self in the project and find this file:
thinkphp.php

if(IS_CGI) {            //CGI/FASTCGI模式下            $_temp  = explode('.php',$_SERVER['PHP_SELF']);            define('_PHP_FILE_',   rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp[0].'.php'),'/'));        }else {            define('_PHP_FILE_',    rtrim($_SERVER['SCRIPT_NAME'],'/'));        }

That is, thinkphp relies on php_self in CGI mode, and the problem is here.
Finally Baidu again, originally is php.ini in order to shield a flaw set up:

cgi.fix_pathinfo=0

It is this line setting that causes the value of the php_self to deviate.

However, the pathinfo.conf in the LNMP integration pack has been used

$fastcgi_script_name =404

Resolves this vulnerability, so we can modify php.ini to

cgi.fix_pathinfo=1

Restart the server, OK, problem solving

The above describes the Nginx server under the use of thinkphp PathInfo model, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.