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
url-rewriting nginx


source to share


No one has answered this question yet

See similar questions:

3
How to stop error 400 when URL contains percent character%? (Apache)

or similar:

2170
How can I change the url without reloading the page?
954
Node.js + Nginx - Now What?
1
NGINX Rewrite one HTTPS URL to HTTP
0
Redirecting with nginx
0
web.config rewrite rule for paths
0
IIS Rewrite Http URL for Https, exclude one URL
0
Nginx: how to add a rewrite rule to redirect all requests to file type?
0
Nginx rewrites url to get clean url
0
nginx ignore / en in url



All Articles
Loading...
X
Show
Funny
Dev
Pics