Nginx does not support pathinfo functions

Source: Internet
Author: User

Server {Listen the;        server_name www.domain.com domain.com; Error_page404/404. html; Error_page - 502 503 504/50x.html; Location~\.php {root/data0/htdocs/www; Fastcgi_pass127.0.0.1:9000; #包含nginx服务器传递给fastcgi程序的参数, PHP through $_server['Name of parameter'] access to include fastcgi.conf; #定义变量 $fastcgi _script_name_new assignment to $fastcgi_script_name variableSet$path _info""; Set$fastcgi _script_name_new $fastcgi _script_name; if($fastcgi _script_name ~*"^ (. +\.php) (/.+) $") {                        Set$fastcgi _script_name_new $1; Set$path _info $2;   The Script_filename and script_name fastcgi parameters in the #对fastcgi. conf are overridden Fastcgi_param                        Script_filename $document _root$fastcgi_script_name_new;                        Fastcgi_param script_name $fastcgi _script_name_new;        #定义一个新的nginx服务器传递给fastcgi的参数PATH_INFO, thinkphp need this parameter Fastcgi_param path_info $path _info; } Location/{root/data0/htdocs/www;                Index index.html index.htm; if(!-e $request _filename) {Rewrite^ (. *) $/index.php$1Last ; }        }    }

TP Support Phpinfo

Step Two: Open the configuration file for the thinkphp framework convention.php,

Modify the url_model=>1, use the pathinfo mode, do not set to 2 Ah, because Nginx rewrite added the index.php entry file.

Step three: In the browser input: www.domain.com, the results are as follows:

:)

Welcome to use thinkphp!

[You are now visiting the index controller of the home module]

Fourth step: Enter the URL in the browser, in the form of rewrite URL, is not to enter the entry file, the other unchanged and pathinfo mode, for example:
http://www.domain.com/module/controler/action/parameter 1/value 1/Parameter 2/value 2/

It is no longer necessary to enter the entry file index.php in the URL, because we have already specified the import file index.php when we have just rewritten.

Step Two: Open the configuration file for the thinkphp framework convention.php,

Modify url_model=>3, use rewrite compatibility mode, and modify
' Var_pathinfo ' = ' s ', when rewritten we use the form of s= "".

Step three: In the browser input: www.domain.com, the results are as follows:

:)

Welcome to use thinkphp!

[You are now visiting the index controller of the home module]

Fourth step: Enter the URL in the browser, or use the rewrite form of the URL, is not to enter the entry file, the other unchanged, for example:
http://www.domain.com/module/controler/action/parameter 1/value 1/Parameter 2/value 2/

It is no longer necessary to enter the entry file index.php in the URL, because we have already specified the import file index.php when we have just rewritten.

Nginx does not support pathinfo functions

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.