Nginx rewrite 去 query_string和 分析query实战
location ^~ /R {
if ( $query_string ~ ^i=(.*)&t=a(.*) ) {
set $a $1;
set $b $2;
rewrite ^/(.*) https://www.xxx.yyy.com.cn:9100/m.html#/home?id=${a}&Type=Asset${b}? permanent;
}
rewrite ^/(.*) https://www.xxx.yyy.com.cn:9100/m.html#/home permanent;
}
注:
1. 一定要在 rewrite 的最后面加 ?号来去掉query_string。如上面的 ?放在了最后的Type=Asset{b}后面。
缺省情况下rewrite会把query_string 补 到新的URI后面的!
2. 如何分析query_string,则见上面
本文详细介绍了如何使用Nginx rewrite模块去除query_string及分析query_string中的参数,通过具体的配置示例,展示了如何根据query_string中的参数进行重写,以实现对请求的灵活处理。
1946

被折叠的 条评论
为什么被折叠?



