Nginx Rewrite Rule for Special Charachter

1

1

I have one URL as www.xyz.com/api/abcdefgh^ijklmn.

I want to redirect this URL www.xyz.com/api/abcdefgh%5ijklmn.

Can some one suggest what will be Nginx Redirect rule for this.

Saurabh Agrawal

Posted 2018-04-19T13:15:50.027

Reputation: 11

Answers

0

Wrote a Redirect Rule and it working perfectly fine.

if ($request_uri ~ ^(/.*)[\^](.*)$) {
  return 301 $1%5E$2;
}

Just make sure you are writing this in location directive.

Saurabh Agrawal

Posted 2018-04-19T13:15:50.027

Reputation: 11