Rewriting ASCII-percent-encoded locations to their UTF-8 encoded equivalent
See here for the same issue in Apache - there, I recommended using an external program to handle the rewrite, since it's clunky to do it in native configuration.
For nginx, the best approach might be to embed some perl in your configuration via ngx_http_perl_module
- use perl_set
to set a variable to a UTF-8-ified version of $r->uri
, using the Encoding
module (see here), and rewrite (or probably better, try_files
) to that.
Edit:
If you want to just do this by hand for specific URLs or specific characters, then you're just missing a couple things in your attempts:
- You're working against escaped URLs, while the rewrite should be happening against the string after decoding escaped characters
- You're hardcoding the matches to be for files that are just the special character, not files that contain the special character
Try something like this..
rewrite (*UTF8)^(.*)\xe5(.*)$ %1å%2;