How to write a rewrite for the Nginx that will take into account only certain parameters of query:
For example, I have a query:
site.com/guru/?g=guru1&skill=basic&unwanted=garbage
I want to receive:
site.com/guru/?g=guru1&skill=basic
I think about: 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;
}
Thank.