Problem Found: Use ThinkPHP3.2.2 to deploy the website on nginx, set URL_MODEL2, and use the U method to generate a link locally, for example: publicindex is deployed on nginx but there is a problem where the URL is generated. publicindex trace the ThinkPHP source code in ThinkPH... problems found:
Use ThinkPHP3.2.2 to deploy the website in nginx, set URL_MODEL = 2, and use the U method to locally generate a link, for example,/public/index.
However, a problem occurs when deployed on nginx. The URL generates./public/index.
The following code is found in the ThinkPHP. php file by searching for the ThinkPHP source code:
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'], '/'));}
This is the root cause of the problem.
Access: http: www.xxx.com/public/index
Under apache$_SERVER['PHP_SELF']
Display./index. php/public/index
While nginx is blank
Access: http: www.xxx.com/index.php/public/index
Under apache$_SERVER['PHP_SELF']
Display./index. php/public/index
Display/public/index in nginx
At last, it was found that the PATH_INFO feature in nginx encountered a strange problem.
In my nginx, The PATH_INFO section is configured as follows:
Fastcgi_split_path_info ^ (. +? \. Php) (/. *) $; set $ path_info $ fastcgi_path_info; fastcgi_param PATH_INFO $ path_info; # try_files $ fastcgi_script_name = 404 if this line of PHP_SELF is set;
Reply content:
Problems found:
Use ThinkPHP3.2.2 to deploy the website in nginx, set URL_MODEL = 2, and use the U method to locally generate a link, for example,/public/index.
However, a problem occurs when deployed on nginx. The URL generates./public/index.
The following code is found in the ThinkPHP. php file by searching for the ThinkPHP source code:
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'], '/'));}
This is the root cause of the problem.
Access: http: www.xxx.com/public/index
Under apache$_SERVER['PHP_SELF']
Display./index. php/public/index
While nginx is blank
Access: http: www.xxx.com/index.php/public/index
Under apache$_SERVER['PHP_SELF']
Display./index. php/public/index
Display/public/index in nginx
At last, it was found that the PATH_INFO feature in nginx encountered a strange problem.
In my nginx, The PATH_INFO section is configured as follows:
Fastcgi_split_path_info ^ (. +? \. Php) (/. *) $; set $ path_info $ fastcgi_path_info; fastcgi_param PATH_INFO $ path_info; # try_files $ fastcgi_script_name = 404 if this line of PHP_SELF is set;
This $ _ SERVER has a lot to do with SERVER configuration.
Try_files $ fastcgi_script_name = 404; you can remove it. $ _ SERVER ['php _ SELF '] will have
You do not need to remove try_files $ fastcgi_script_name = 404. This configuration addresses the security vulnerability when cgi. fix_pathinfo is set to 1 in php. ini. This error is caused by the configuration of cgi. fix_pathinfo = 0 on the php. ini server of the landlord.