How to redirect an encoded url slug with Nginx

Viewed 341

I have a strange url, (/%E2%80%8E) from an older version of a site that needs to be redirected to (/). I tried the following but it did not work:

location /%E2%80%8E {
  return 301 /;
}

Any help would be appreciated!

1 Answers

You cannot use percent encoded URIs in the location statement.

I managed to match the URI by using three hexadecimal bytes. The regular expression syntax incudes a method for inserting arbitrary byte values by using the \x escape sequence.

For example:

location ~ ^/\xE2\x80\x8E { return 301 /; }
Related