/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