Rewrite url containing percentage signs with nginx

My site needs to accept what is essentially a wrong URL submitted by another site:

http: // mysite /% SAMPLE_URL_STRING%

and redirect it to the correct url using nginx. None of the rewrite rules I've tried seemed to catch it, instead it always returned 400 instead.

Since the one percent sign, which does not describe an encoded character, is itself an unsafe character as described in the RFC ( http://www.ietf.org/rfc/rfc1738.txt ) I suppose this can be an insurmountable problem.

However, fetching rules for (non-functional) rewriting include:

rewrite /%SAMPLE_URL_STRING% /redirect.html permanent;
rewrite ^/\%SAMPLE_URL_STRING\%$ /redirect.html permanent;
rewrite /\%.*\% /redirect.html permanent;

      

Even coming into UTF8:

rewrite (*UTF8)^\x25.*\x25$ /redirect.html permanent;

      

Is it possible that any url containing% SAMPLE_URL_STRING% cannot be redirected by nginx?

+3


source to share





All Articles