Nginx default does not support the pathinfo format of the URL, recently learned thinkphp Url_model encountered this problem. Apache server open Rewrite, will allowoverride set to all OK, but nginx needs further configuration, online to find a lot of tutorials, mostly reproduced more, tried several have not succeeded. Later, according to another tutorial configuration, the results are OK. Here is the configuration process.
1.NGINX.CONF is configured as follows server { listen 80 ; server_name test.com; index index.php; root D:/phpStudy/WWW/test; #这里是开启rewrite隐藏index .php location / { if (!-e $request _filename) { # -e indicates that a file or directory exists rewrite ^ (. *) $ /index.php/$1 last; #last相当于apache中的 [L], which means no more matching down break; } } #这里是pathinfo的配置 location ~ \ . php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; set $real _script_name $fastcgi _script_name; if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $ ") { set $real _script_ name $1; set $path _info $2; } fastcgi_ param script_filename $document _root$real_script_name; fastcgi_param SCRIPT_NAME $real _script_name; Fastcgi_param&nbsP path_info $path _info; } }
Configuration in 2.hosts files
127.0.0.1 test.com
OK, open the browser and try it, Http://test.com/Home/Index/index, Euler!
Nginx Configuration PathInfo