Forum Moderators: phranque
www.mysite.com/buy/123
to
www.affiliatesite.com/my_id=12345&product_id=123&other_variable=2
With the only thing chaning in the links is the product_id. I've tried the following and neither work:
redirect /buy/(.*)$ [affiliatesite.com...]
And then I tried:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^buy/(.*)$ [affiliatesite.com...]
And now I'm completely stumped. I've just spend a couple of hours on the web looking for a solution (including the apache site). I don't suppose anybody here has an idea how to do this?
I should add that I have hundreds of URLS to redirect so I have to use a variable in the redirect process (as opposed to typing each redirect into the htaccess file)
Any help would be very much appreciated. Thanks.
And then I tried:Options +FollowSymLinks
RewriteEngine On
RewriteRule ^buy/(.*)$ http://www.affiliatesite.com/my_id=12345&product_id=$1&other_variable=2And now I'm completely stumped. I've just spend a couple of hours on the web looking for a solution (including the apache site). I don't suppose anybody here has an idea how to do this?
You won't be able to do this transparently with your code -- in other words, the URL in the address bar will change. However, maybe that's not the problem. If it is the problem, then maybe you can proxy the request to the other site. But we need to know precisely what you intend to do, specifically what isn't working, and any errors you see in your server error log (if applicable).
Jim
I essentially want to implement:
redirect /buy/123456 [affiliatesite.com...]
redirect /buy/7891020 [affiliatesite.com...]
redirect /buy/9876546 [affiliatesite.com...]
. .
. .
. .
And so on
But instead of writing several hunbred redirects as above, I'm trying (and failing) to do it in one line (or a few lines). I think the modrewrite I was trying above was not the correct way to go about it. When I tried the redirect method that I mentioned in my first post I get the following error:
File does not exist: /home/myusername/public_html/buy/123456
I presume that this error is because the redirect isn't associating the 123456 with the (.*)$
Very confused. Thanks again,
Iain.