Nginx Configuration PathInfo

Source: Internet
Author: User

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

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.