Nginx Pseudo-static rules

Source: Internet
Author: User

Nginx Pseudo-static rules

To rewrite the http://lovo.com/index.php?t=3 with pseudo-static rules into http://lovo.com/t3.html, you can add in the Nginx conf/nginx.conf.

Add in Location/{}, such as:

        location/{
             root  /var/www/html;
            index   index.php index.html index.htm;
            rewrite ^ (. *)/T (\d+) \.html$ $1/index.php?t=3 last;
       }

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;


Case:

Location /{
# # #以下为PHPCMS pseudo-staticrewriterules
rewrite ^ (. *) show-([0-9]+)-([0-9]+) \.html$ $1/show.php?itemid=$2&page=$3;
rewrite ^ (. *) list-([0-9]+)-([0-9]+) \.html$ $1/list.php?catid=$2&page=$3;
rewrite ^ (. *) show-([0-9]+) \.html$ $1/show.php?specialid=$2;

# # # #以下为PHPWind pseudo-static rewrite rules
rewrite ^ (. *)-htm-(. *) $ $1.php?$2 last;
rewrite ^ (. *)/simple/([a-z0-9\_]+\.html) $ $1/simple/index.php?$2 last;
                      }


This article from "TT's it big Miscellaneous, Welcome to join ~" blog, declined reprint!

Nginx Pseudo-static rules

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.