Nginx redirect Pseudo-static rewrite index.php

Source: Internet
Author: User

Tag: base on base Yes details views file pseudo static thinkphp proxy

Reference https://www.kancloud.cn/manual/thinkphp5/177576

Add the thinkphp entry file in the same directory. Save the following content as a. htaccess file

<ifmodule mod_rewrite.c>
Options +followsymlinks-multiviews
Rewriteengine on

Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php?/$1 [qsa,pt,l]
</IfModule>

Server

Vim/usr/local/nginx/conf/vhost/www.phpaaa.com.conf

Write code in http{server{}} and write around the original location

Location/{

if (!-e $request _filename) {

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

}

}

Restart

Lnmp start

Usage scenario: I want to enter WWW.ABC.COM/A/1 and actually jump to WWW.ABC.COM/INDEX.PHP/A/1


Configure nginx.conf to add under your virtual host:
Location/{
if (!-e $request _filename) {
Rewrite ^/(. *) $/index.php/$1 last;
}
}


If your project portal file is within a subdirectory, then:
Location/directory/{
if (!-e $request _filename) {
Rewrite ^/directory/(. *) $/directory/index.php/$1 last;
}
}

Nginx master configuration (default virtual Host) file:/usr/local/nginx/conf/nginx.conf

Add the Virtual Host Profile:/usr/local/nginx/conf/vhost/domain name. conf

http://blog.csdn.net/beyondlpf/article/details/8261657

Http://www.cnblogs.com/300js/p/6484642.html

Careful observation rewrite ^ (. *)/T (\d+) \.html$ $1/index.php?t=3 last; in fact, I feel nginx pseudo-static rules are very good to write. is to use a regular basis, a rewrite to declare, and then ^ is a pseudo-static rules, (. *) match any character, here is the domain name, T is the character you want to add here, such as you can add apple, orange, such as the name of the category, (\d+) matches the number, \. The HTML matches the suffix, and $ is the end of the regular match. The latter part is to rewrite the URL, with a start, representing the domain name,/index.php?t=3 is to rewrite the URL, with last;

Source: http://www.cnblogs.com/thinksasa/archive/2012/12/16/2820130.html

Rewrite ^ (. *)/T (\d+) \.html$ $1/index.php?t=3 last;

Rewrite enter the URL to jump to the URL last;

==========================

(-D $request _filename) It has a condition that is required for the real directory, and my rewrite is not, so no effect

if (-D $request _filename) {

Rewrite ^/(. *) ([^/]) $/HTTP $host/$1$2/permanent;

}

=====================

Redirects when files and directories do not exist:

Copy the code code as follows:

if (!-e $request _filename) {

Proxy_pass http://127.0.0.1;

}

=====

Nginx redirect Pseudo-static rewrite index.php

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.