thinkphp Nginx support for PathInfo in a low version of the _php technique

Source: Internet
Author: User
Tags nginx server

Recently in the use of thinkphp to do a project, basically completed after deployment to the Nginx server to find that Nginx is not support pathinfo so how do we deal with it.

Nginx Environment

In the Nginx version, the pathinfo is not supported, but can be passed in nginx.conf (in/usr/local/nginx/conf/nginx.conf or through Find/| grep nginx.conf to find locations) Configure the forwarding rule implementation: Add in the Nginx configuration file:

Location/{ 
if (!-e $request _filename) {
   rewrite ^ (. *) $/index.php?s=$1 last;
   break;
 }
} 

In fact, the internal is forwarded to the thinkphp provided by the compatibility mode of the URL, in this way, you can resolve other unsupported PathInfo Web server environment.
If your thinkphp is installed in level two directory, Nginx's pseudo static method is set as follows, where Youdomain is the directory name.

location/youdomain/{
 if (!-e $request _filename) {
  rewrite ^/youdomain/(. *) $/youdomain/index.php?s=$1 last;
 }
} 

Such as:

location/thinkphp/{
 if (!-e $request _filename) {
    rewrite ^/thinkphp/(. *) $/thinkphp/index.php?s=$1 last;
 }
}

Syntax: Rewrite regex replacement flag (last equivalent to the [L] tag inside Apache, representing rewrite. )

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.