Jump to content

PHP affiliate redirect script


rodrico101

Recommended Posts

Hi,

 

I am looking to write a script that redirects my affiliate links to their appropriate sites.

 

I want to have this as my clickable link:

 

www.mysite.com/recommends/ebay.com 

 

I prefer not to have "id" in my redirect and want the link in the above form.

 

Have a good idea how to start, but am coming up short.

 

Any help would be greatly appreciated.

 

Rod

Link to comment
https://forums.phpfreaks.com/topic/119740-php-affiliate-redirect-script/
Share on other sites

Use output buffering and headers.

 

ob_start();

 

if (strpos($url,"mysite.com/taco))  {

  header("Location: http://redirected_absolute_url");

  }

else if  (strpos($url,"mysite.com/hamburger))  {

  header("Location: http://other_site");

  }

else if(strpos($url,"mysite.com/whatever))  {

  header("Location: http://where_ever");

  }

 

$ob_contents = ob_get_contents();

ob_end_clean()

echo $ob_contents;

 

Although in this example you dont really need output buffering cuz Im not defining any variables, I have a feeling you'll have use for it in the future.  Could also use a meta-refresh html tag also...

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.