Apache 2.2.7以下でBと同じものを使う
mod_rewriteの[B]。本家曰く
The [B] flag instructs RewriteRule to escape non-alphanumeric characters before applying the transformation. mod_rewrite has to unescape URLs before mapping them, so backreferences will be unescaped at the time they are applied. Using the B flag, non-alphanumeric characters in backreferences will be escaped. For example, consider the rule:
エスケープしてくれるようですが、2.2.7以下では使えません。
別途関数を書く必要があるようです