I'm coping with a mature website that regrettably has images saved sometimes as

kitty%2Bcat.jpg (literally with %2B inside)

but sometimes as


(either, not both will exist)

Regrettably whenever a browser constitutes a request cat%2Bcat.digital it never tries to obtain the literal filename with this - if cat+cat.digital is available, it'll serve it, otherwise, it 404s

Can One apply certain mod-rewrite rules to ensure that if cat%2Bcat.digital is asked for but cat+cat.digital doesn't exist and cat%2Bcat.digital does, cat%2Bcat.digital is offered?

I'm imaging a few of the logic involved but nonetheless missing some pieces.

RewriteCond %{REQUEST_FILENAME} \%2B
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . %{REQUEST_FILENAME} [L]

See - how do you pressure apache for everyone it literally and never 404 ?

Possibly apache really sees it as being cat+cat rather than will get an opportunity to examine it as being %2B, so I must make a move else such as this?

RewriteCond %{REQUEST_FILENAME} \+
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\+(.*)$ $1\%2B$2 [L]

But regrettably that's not robust enough because there might be multiple %2B along with other encodings.

Try the [NE] No-Escape flag http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule


RewriteCond %{REQUEST_FILENAME} !-f [NE]

Shot at nighttime, appears it might work