I have a third-party shopping cart set up on my server using PayPal for payments. When a user completes a transaction they are redirected to the URL https://example.com/?target=payment%255freturn&txn_id_name=txnId...
. The correct URL should include target=payment_return
or target=payment%5freturn
. These URLs work correctly, presenting the customer with their invoice, but the URL that PayPal redirects to is URL encoded twice and so gives the customer a 404 error.
I cannot change the logic of the application to accept the twice-escaped URL so I have been trying to set up a redirect to correct it. I've tried numerous variants on the following, using mod_alias or mod_rewrite:
RedirectMatch permanent (?i)^/\?target=payment%255freturn(.*) /target=payment_return$1
RewriteRule ^/\?target=payment%255freturn(.*) /target=payment_return$1 [NE]
I've tried variations of %255f, %5f, and _, and I've tried with and without the NE flag.
How can I have the user successfully redirected to the correct URL?