I\'m trying to issue a redirect where the destination contains a fragment-identifier part. I tried with this rule:
RewriteRule ^/foo/bar/([^/]+)/(.*)$ /cgi/s
Solution found: there is an option for not escaping urls with mod_rewrite:
https://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne
Adding the [NE] flag solved the problem.