I must decode asked for URL via .htaccess/mod_rewrite and forward it to my PHP application. I'm making request with a remote service and I have to preserve the URL for redirecting after processing the remote request. I'm handling it in forward GET parameter so I have to scribe it via urlencode. I'd like it decode then via .htaccess so there's no additional and wasting PHP request and I am trying following:

RewriteCond %{QUERY_STRING} ^(.*)%3F(.*)$
RewriteRule ^(.*)$ $1?%1&%2 [N]

RewriteCond %{QUERY_STRING} ^(.*)%3D(.*)$
RewriteRule ^(.*)$ $1?%1=%2 [N]

And delay pills work really strange. Second RewriteCond statement matches substring "%253D" and replaces it using the right "=" character. It's strange it matches already encoded % (%25) while my rule consists of only %. But further within the URL there's only %three dimensional, that we should also decode to =, but I'm not sure how.

Thank you for any help.