Pathinfo mode of ThinkPHP in Nginx server

Source: Internet
Author: User
: This article describes how to use the pathinfo mode of ThinkPHP on the Nginx server. if you are interested in the PHP Tutorial, refer to it. The pathinfo mode of thinkphp cannot be used after one-click LNMP installation and packaging.
Baidu once found that pathinfo is enabled in the nginx/conf/vhost/domain name file, so pathinfo is started.
But the project still cannot run, so I ran the code both locally and on the server:


  

The difference between PHP_SELF and so may be found here.
Search PHP_SELF in the project and find the file:
ThinkPHP. php

If (IS_CGI) {// CGI/FASTCGI mode $ _ 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 depends on PHP_SELF in cgi mode. The problem is true here.
In the end, Baidu again. it was originally set in php. ini to block a vulnerability:

cgi.fix_pathinfo=0

It is precisely because of this row setting that the PHP_SELF value is deviated.

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

try_files $fastcgi_script_name =404

Solve this vulnerability, so we can modify php. ini

cgi.fix_pathinfo=1

Restart the server, OK, and solve the problem

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.