Nginx??Map??????ü????????
???????????? ???????[ 2016/9/22 15:54:36 ] ??????????????? Nginx
????????????leetcode????????????????????????????????????????????????????leetcode????????????????????????????????~
?????????????????????????????????к??????????????????????????????е??????????????в??????????????????????????????????????url-mapping???????????????
???????url-mapping???????ζ??????
?????????????μ???????????????discuss????????? phpbb ???????? nodebb ??????? url routing ???????????????????topic??
???????????url??:
????http://hostname/discuss/<topic_id>/<topic_name>
???????μ????????:
????http://hostname/topic/<topic_id>/<topic_slug>
????(?????????????????? topic_id ???????????????)??
??????????????????????У????????url??????????????????????????????????????Щ?????Ч???????????????????????url??????????????????????????????????url-mapping??????
????????
????????url-mapping
??????л nodebb-plugin-import ?????????????????????url-mapping??????????????д?????????Щmapping?????????mapping????????????:
????~^/discuss/questions/oj/add-two-numbers(?[^/]*)*/?$ /category/10/add-two-numbers;
???????е? slug ?? id ??mapping???????????? regular expression ????????url???????param?????
????Nginx Map
?????????? ??demo???????????????????????????????????????????????????:
http {
...
map_hash_max_size 204800;
map_hash_bucket_size 204800;
map $request_uri $new {
include /path/of/your/map/file;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
...
}
server {
...
if ($new) {
rewrite ^ https://discuss.leetcode.com$new redirect;
}
location / {
...
}
...
}
??????server????????У?$new???????????????????url?????http????mapping?????????????????????? location ?????????rewrite???μ????? ? :???????????proxy_pass??У??????????в?????proxy_pass??????????????????nginx?????????????????rewrite??????????????
????????
?????????mapping??????е???????????????????????????????????????????????mapping??????У????mapping??????hash???????????????????????????Щ????????????????????????????
???????????:
????1?????????????helloworld
????2????????????100??url-mapping?????????helloworld
????3?????abtest????helloworld?????url?????
????4??????url-mapping??????????1??2
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11