Reputation: 5113
PayPal are annoying...if you have thousands of customer subscriptions which POST
IPN's (Instant Payment Notifications) to a certain URL...you can never change that URL. If you want to have the IPN's sent to another URL, their advice...tell all your customers to cancel their subscriptions and start new ones after you've changed the IPN URL. Great.
So after digging around, a solution I found is to use a 307 redirect which will not only redirect to a new URL, but carry along the POST
data with it. but I'm having a little trouble with that in Apache. It doesn't seem to work at all. Here is the line in my .htaccess
file:
Redirect 307 /index.php?view=account&task=paypal https://api.anotherdomain.com/paypal/ipn
What would be the reason this doesn't redirect?
Upvotes: 3
Views: 4050
Reputation: 41219
You can't match against querystring using a Redirec directive. You need to match against %{QUERY_STRING} variable using mod-rewrite. The following rule does what you want :
RewriteEngine on
RewriteCond %{QUERY_STRING} ^view=account&task=paypal$ [NC]
RewriteRule ^/?index\.php$ http://example.com/paypal/? [R=307,L]
? at the end of the destination url is important as it avoids appending old querystring to the new url.
Upvotes: 4