Nginx configuration supports thinkphp's Path_info_nginx

Source: Internet
Author: User

Overview

Today encountered a problem, ubuntu+nginx+mysql configuration thinkphp project, did half found, Nginx not support thinkphp path_info mode, Baidu for a long time, in a friend's help to solve, record.

Nginx supports Thinkphp's path_info

Environment

Ubuntu 14.04+nginx+mysql. All programs are installed through Apt-get, so the Nginx configuration file path is/etc/nginx/sites-available/default.

Solving method

Navigate to the following sections of the Nginx configuration file:

Copy Code code as follows:
Location/{
# Attempt to serve request as file, then
# as Directory, then fall back to displaying a 404.
Try_files $uri $uri/= 404;
# Uncomment to enable NAXSI on this location
# Include/etc/nginx/naxsi.rules
}

Add the following code:
Copy Code code as follows:

if (!-e $request _filename)
{
Rewrite ^/myapp/(. *) $/myapp/index.php?s=$1 last;
Break
}

The regular wording of the writing

Solve this problem, see several solutions, light is to see a few, also do not know which is the most standard, I am not very familiar with the first record down, and then slowly study:
Regular 1:

Copy Code code as follows:

Rewrite ^/myapp/(. *) $/myapp/index.php/$1 last;

Regular 2:
Copy Code code as follows:

Rewrite ^ (. *) $/index.php?s=$1 last;

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.