rewrite – How Check Url Parametr and Redirect with Nginx

I want to check if a parameter is present in a url in nginx and then rewrite.How can i do that?

For e.g if url is website.com/Cat-8/ID-1/Ads-4-3?page=1 then redirect user to website.com/Cat-8/ID-1/Ads-4-3

Only redirect page with Cat- and end with ?page=1

E.G:

http://website.com/Cat-8/ID-1/Ads-4-3?page=1

redirect to

http://website.com/Cat-8/ID-1/Ads-4-3

Another E.G:

http://website.com/node/Item21?page=1

for example i dont want this pages redirect

http://website.com/node/Item21?page=1

With my code all url has been redirect !

there is :

if ($arg_page != “”) { return 301 $uri; }

Read more here: Source link