如何为 Nginx 编写重写,该方法将仅考虑查询的某些参数
例如,我有一个查询:
site.com/guru/?g=guru1&skill=basic&unwanted=garbage
我想收到:
site.com/guru/?g=guru1&skill=basic
我考虑: https://stackoverflow.com/a/35772678/1895392
if ($request_uri ~ "([^\?]*)\?(.*)unwanted=([^&]*)&?(.*)") {
set $original_path $1;
set $args1 $2;
set $unwanted $3;
set $args2 $4;
set $args "";
rewrite ^ "${original_path}?${args1}${args2}" permanent;
}
谢谢。