Nginx supports thinkphp pathinfo

Source: Internet
Author: User
Nginx pathinfo that supports thinkphp now finds two problems:
1 does not support PATHINFO.
Localhost /? M = login is accessible, while localhost/login is not.
2. the address generated by the U method of THINKPHP is incorrect.
The address generated by U ('login/index') is a/login-index.html.

Nginx configuration file:
Location ~ \. Php $ {
Root D:/AppServ/www;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;

Set $ path_info "";
Set $ real_script_name $ fastcgi_script_name;
If ($ fastcgi_script_name ~ "^ (. +? \. Php) (/. +) $ "){
Set $ real_script_name $1;
Set $ path_info $2;
}
Fastcgi_param SCRIPT_NAME $ real_script_name;
Fastcgi_param PATH_INFO $ path_info;

Include fastcgi_params;
}

. Htacess:

RewriteEngine on
RewriteRule ^ (. *) $ index. php/$1 last


Nginx error log:
13:54:42 [error] 5404 #5668: * 107 CreateFile () "D:/AppServ/www/login" failed (2: The system cannot find the file specified), client: wagner. 0.0.1, server: localhost, request: "GET/login HTTP/1.1", host: "localhost"


Reply to discussion (solution)

This will set the location ~ \. Php $ {changed to location ~ \. Php /?. * $ {And location ~ . + \. Php ($ |/) {. it is useless after nginx-s reload.

server {       listen  80;       server_name     www.phpno.com;       root /home/www/www_phpno_com/admin_wwwroot;       access_log off;       error_page 404  /404.html;       location /404.html {               root /home/www/www_phpno_com/admin_wwwroot;       }       location /{               index index.html index.htm index.php;               if (-e $request_filename) {                       break;               }               if (!-e $request_filename) {                       rewrite ^/(.*)$ /index.php/$1 last;                       break;               }       }        location ~ .+\.php($|/) {           root           /home/www/www_phpno_com/admin_wwwroot;           fastcgi_index index.php;           fastcgi_split_path_info ^(.+\.php)(.*)$;           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;           fastcgi_param   PATH_INFO               $fastcgi_path_info;           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;           fastcgi_pass   127.0.0.1:9000;           include        fastcgi_params;       }   }
Compare it by yourself

server {       listen  80;       server_name     www.phpno.com;       root /home/www/www_phpno_com/admin_wwwroot;       access_log off;       error_page 404  /404.html;       location /404.html {               root /home/www/www_phpno_com/admin_wwwroot;       }       location /{               index index.html index.htm index.php;               if (-e $request_filename) {                       break;               }               if (!-e $request_filename) {                       rewrite ^/(.*)$ /index.php/$1 last;                       break;               }       }        location ~ .+\.php($|/) {           root           /home/www/www_phpno_com/admin_wwwroot;           fastcgi_index index.php;           fastcgi_split_path_info ^(.+\.php)(.*)$;           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;           fastcgi_param   PATH_INFO               $fastcgi_path_info;           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;           fastcgi_pass   127.0.0.1:9000;           include        fastcgi_params;       }   }
Compare it by yourself


Thank you for your enthusiastic moderator.
I changed it according to the configuration you posted, except for the path. But still not. My nginx version is 1.6.2. Error log or
CreateFile () "D:/AppServ/www/login" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET/login HTTP/1.1", host: "localhost"

My current configuration file is like this:

location / {            root   D:/AppServ/www;             index  index.php index.html index.htm;if (-e $request_filename) {                       break;               }               if (!-e $request_filename) {                       rewrite ^/(.*)$ /index.php/$1 last;                       break;               }        }location ~ .+\.php($|/) {            root           D:/AppServ/www;            fastcgi_index  index.php;            fastcgi_split_path_info ^(.+\.php)(.*)$;fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param   PATH_INFO               $fastcgi_path_info;fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;            fastcgi_pass   127.0.0.1:9000;include        fastcgi_params;        }

Configuration above... I restarted my computer just now... Okay...

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.