Forum Moderators: coopster

Message Too Old, No Replies

Redirect from Domain to aff domain? possible?

         

askeli

1:22 am on Sep 26, 2004 (gmt 0)

10+ Year Member



Hi

What i would like to do is setup a PHP/htaccess redirect of some sort to redirect a link to an affiliate link, problem is i would like to keep the aff id in the url

Example:

ht*p://www.mydomain.com/info.php?a=1234&p=?&t=?

or preferably

ht*p://www.mydomain.com/info.php?p=?&t=?

redirects to:

ht*p://www.affiliatesurl.com/click?a=1234&p=?&t=?

What i would like is to keep the last 2 variables if possible as i have over 2000 links and they are deep aff links so creating a simple redirect for every url would result in one crazy .htaccess file as for creating 2000 meta refresh pages! ouch!
If i could implement something like the above with PHP i could do a simple search/replace of www.affiliatesurl.com/click?a=1234& to www.mydomain.com/info.php?

Many Thanks to anyone and everyone who can help.

mincklerstraat

9:18 am on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, quite possible. Make a php script that figures out, on the basis of the parameter you send it, what the link needs to be (incl. aff. id) and make it go there with the header function:
header('Location: h*tp://amazooon.com/afid=mememe');
Then it's a matter of searching/replacing you content either in files or in the db - you can do this simply with str_replace if it's gotta be the db (you'll have to write a script to pull out each entry, search-replace, write over if changed), or if it's files just use a file-wide search-replace in your favorite edior.

askeli

9:36 am on Sep 26, 2004 (gmt 0)

10+ Year Member



thanks, yes thats what im after (i think) but any ideas on how to do it?

Thanks

askeli

1:38 pm on Sep 26, 2004 (gmt 0)

10+ Year Member



Can anyone point me in the right direction please

mincklerstraat

3:47 pm on Sep 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php
//sendmetotheaffiliatewithid.php
$affiliateurl = array(
'amazoooon' => 'h*tp://amazooon.com/click?*1*&p=*2*&affid=*3*',
'shedsarenoble' =>
'h*tp://shedsarenoble.com/whatever?*1*&v=*2*&myid=*3*',
'booksrus' =>
'ht*tp://boooksrus.com/f?*1*&df=*2*&payme=*3*';
);
if(!empty($_GET['aff']) &&!empty($affiliateurl[$_GET['aff']])){
$redirect = $affiliateurl[$_GET['aff']];
if(!empty($_GET['first'])) $redirect = str_replace('*1*', $_GET['first'], $redirect);
if(!empty($_GET['second']) $redirect = str_replace('*2*', $_GET['second'], $redirect);
$redirect = str_replace('*3*', $_GET['aff'], $redirect);
header('Location: '.$redirect);
} else die('something didn\'t work here');
?>
Just make links to sendmetotheaffiliatewithid.php?aff=amazoon&first=1234&second=5678
where aff is what you filled in to the left part of the arrow above, first is what you want to come in the place of *1*, and second is what you want in the place of *2*, and *3* is the part that needs to be your affiliate id. Note: not tested, you might have to debug.

askeli

8:02 pm on Sep 26, 2004 (gmt 0)

10+ Year Member



Thank you very much got it working perfect :)