This question is related to Apache RewriteMap with URLs containing space doesn't work, but in this case the issue is a space in the value part of the map, not the key part. Say I have this entry:
/a-normal-url/ /a-less-normal url/
As a RewriteMap
's txt
files are space separated, this won't work as-is. I've thus tried to escape the space:
/a-normal-url/ /a-less-normal%20url/
Unfortunately mod_rewrite
will helpfully escape the redirect target, so this will lead to the request being redirected to /a-less-norma%2520url/
, which also isn't what I want.
Just in case, I've also used a backslash to escape the space (/a-less-normal\ url/
), but unsurprisingly this also didn't help (it will redirect to (/a-less-normal%5c
) in that case.
I've actually realized what the answer was when writing the question (classic case of rubber duck debugging).
Just add the
NE
flag in theRewriteRule
that actually uses the rewrite map's output, somewhere along these lines: