'Nginx redirect issue which has query string and special characters

We have configured Nginx web server for our project. We have a requirement to redirect the url which has query string and special characters. Below is the URL.

localhost/searchPage.action?keyWord=line%20cards&overRideCatId=N

We tried 301 redirect using below rule but it is not working. rewrite ^/searchPage.action(.)keyWord(.)line%2520cards&overRideCatId(.*)N https://localhost/line-cards/ permanent;

How to redirect special characters in Nginx 301 redirect rules?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source