Can Apache .htaccess convert the percent-encoding in encoded URIs from Win-1252 to UTF-8?
The only way I can think of to make this cleaner while just being within Apache would be to use a RewriteMap
.
Pointing to a txt
for the map replace will force you to do some terrible things to get around the fact that RewriteRule
replaces the entire string and that you'll have to have a RewriteRule
take place for each character in the string (replaced or not).
So instead, I'd say write an external script in whichever language you're comfortable (ideally one that knows how to convert from 1252 to utf-8 without you needing the hardcode the conversions, python comes to mind) that'll take in the full string, make the needed replacements directly (in real code instead of a huge number of mod_rewrite runs), then pass back the fixed up string for replacement.
RewriteMap win1252-to-utf8 prg:/path/to/executable
RewriteRule - ${win1252-to-utf8:%{REQUEST_URI}}