0

How do I rewrite in .htaccess a call to this URL:

www.domain.com/?_wpm_gateway=paypal-standard&_wpm_action=ipn

To point to a new IPN URL (for Paypal payments):

www.domain.com/payments/paypal/ipn

With, obviously, the rest of the parameters in the IPN itself being passed on and sent over to the new URL?

Any idea?

And I need a rewrite rule ONLY if that query/URL is called, as otherwise it should be business as normal, so to speak.

EDIT: I tried this, but didn't work... ideas?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)_wpm_action=ipn(?:$|&)
RewriteRule ^ /payments/paypal/ipn? [NS,L,DPI,QSD]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
0

1 Answer 1

2

You've got it back to front. You tell PayPal what your new IPN URL is either in your merchant settings, or per transaction in the payment parameters you send. You don't redirect the incoming IPN from PayPal. If you were worried about missed IPNs, you would do a silent internal rewrite of the old to new so it can be processed without redirection.


Edit: example of internal rewrite from old url to new. Edit again it should hit the later rule on the next pass, but you can make it happen quicker in that .htaccess

# ensure only rewrite old paypal when query has exactly right parameter
RewriteCond %{QUERY_STRING} (?:^|&)_wpm_action=ipn(?:$|&)
# should only happen on first request and allow the pretty url to be routed normally on the next pass through the rules
RewriteRule ^ payments/paypal/ipn [NS,DPI,QSD]
Sign up to request clarification or add additional context in comments.

7 Comments

Well, I did set the new IPN in Paypal, but that doesn't apply for existing/previous recurring transactions as they still go to the old IPN (if there was a way to update it for all the old transactions too, I would've already done that). And yes, that is why I need this redirect made, as the old IPNs are going to that URL specified and I need them redirected to the new URL.
Hmm, that's still not pushing any of those IPN notifications over to the specified URL for some reason, even though it looks good on paper to me as well.
Sure. See above. Just a standard Wordpress .htaccess (out of the box one).
Back to front again. Put the custom section first, otherwise WordPress gets it before your rule is ever processed. And the edit you posted doesn't contain the correct condition.
Hmm, updated the htaccess file as per your suggestions, and updated the original question with what's in place right now, and it still doesn't work / pass the IPN query over to that new URL.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.