Nginx Rewrite catalog swap

Source: Internet
Author: User

/123/XXX----->xxx?id=123

[[Email protected]default]# pwd/app/www/default[[Email protected]default]# Tree123123└──sss└──index.html1Directory1File[[email protected]default]# Cat123/sss/index.html Cheshi[[email protected]default]# cat/app/server/nginx/conf/rewrite/default. conf #rewrite^/index\.html/index.php last;#if(!-e $request _filename) rewrite ^/(. *) $ index.php last;#if(!-e $request _filename) {Rewrite ^/(. *) $/index.php last;}#if(!-e $request _filename) {return 404;}#if($http _user_agent ~ Firefox) {Rewrite ^ (. *)? $/nginx-firefox/$1 break;}#if($http _user_agent ~ MSIE) {Rewrite ^ (. *) $/nginx-msie/$1 break;}rewrite^/(\d+)/(. +)//$2? id=$1Last, #在这里我犯了个要命的错误, this match is the real URI, and I think it is the URL of the district, so has not been able to achieve!!!
#后来, I found that there was a big "I don't know!!!" (To really understand what a catalog swap is)
default ]# ls123  ssshttp://192.168.1.24/sss/?id=123# under the root of SSS is the REAL request directory!!!!

[Email protected] default]# Curl http://192.168.1.24/sss/?id=123
The SSS under the root is the real directory of the request.

Finally, we can leave only SSS, which is the root directory of the website/app/www/default/sss/index.html

default] # tree/app/www/default//app/www/default/└──sss    └──index.html1  1 File
[[Email protected]default]# cat/app/server/nginx/conf/rewrite/default. conf #rewrite^/index\.html/index.php last;#if(!-e $request _filename) rewrite ^/(. *) $ index.php last;#if(!-e $request _filename) {Rewrite ^/(. *) $/index.php last;}#if(!-e $request _filename) {return 404;}#if($http _user_agent ~ Firefox) {Rewrite ^ (. *)? $/nginx-firefox/$1 break;}#if($http _user_agent ~ MSIE) {Rewrite ^ (. *) $/nginx-msie/$1 break;}rewrite^/(\d+)/(. +)//$2? id=$1Last ; #location~ ^/(cron|templates)/{deny all; Break;} #location~ ^/data {deny all;} #location^~/html/m.js {access_log off;root/app/www;expires5; Break;} #rewrite^/ck-([0-9]+)-([0-9]+)-([0-9]+) \.html$/ck/$1/$2/$3. html last; #rewrite^/([0-9a-z]+) espressos/(. *) $/web01/$1/$2permanent; #rewrite^/([0-9a-z]+) espressos/(. *) $/web01/$1/$2Last ; #location/i/{alias/data/w3/bass/;} [[Email protected]default]# Curl http://192.168.1.24/sss/?id=123The SSS under the root is the real directory of the request.

Nginx Rewrite catalog swap

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.