Use the $0 backreference rather than %{PATH_INFO} to refer to the input path. In the RewriteRule, add the B flag to escape the URL again (as explained in the mod_rewrite docs). The rest of the rule is there to double-escape the original query string, so that it can be recovered when the url parameter is unescaped by your index.php.

Alternatively, if your index.php expects to use its query string directly rather than decoding it from within the url parameter, you would use

Basically, you're going to be doing the same exact things, only calling RewriteRule instead of url.rewrite-once. Also, one improvement that could be made to both is to use a RewriteCond to match the media part.