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 http://website.com/search/node/item123/loc=33 then redirect to http://website.com/search/node/item123
my code is here and not work !
if ($arg_loc != "") { rewrite ^(/search/.*)$ $1? permanent; }
UPDATE : i want redirect any url that ends with loc=number to the parent url ! for arabic and enlgish characters
EG :
http://website.com/search/node/item123/loc=33
i want redirect to
http://website.com/search/node/item123/
or
http://website.com/search/node/عربیک/loc=55
should be :
http://website.com/search/node/عربیک
if
code cannot work.if
approach is correct. If not, then you need to match on the URL path.