PHP Redirect Rotater

Status
Not open for further replies.

stussy5555

HNIC
Dec 12, 2007
821
10
0
For my affiliate links I redirect them with simple PHP such as:

<?php header( 'Location: LINK ) ;?>

I am sure there is a simple answer to this (not a programmer) but how do I do this same redirect but rotate more than 1 link?

Thanks
 


<?php
if(rand(0,1) == 0) {
header("Location: linkherexxxxxxxxxxx");
} else {
header("Location: linkherexxxxxxxxxxx");
}
?>

I am no coder either, but this is what I use and it gets the job done.
 
For my affiliate links I redirect them with simple PHP such as:

<?php header( 'Location: LINK ) ;?>

I am sure there is a simple answer to this (not a programmer) but how do I do this same redirect but rotate more than 1 link?

Thanks

Fairly easy to do if you can code. I would prefer to do it with an MySQL database, but you could it with a static file.

It could be as simple as using a rand function and an array but you'd not be guaranteed, at least in the short term, to have them rotated evenly.
 
<?php
if(rand(0,1) == 0) {
header("Location: linkherexxxxxxxxxxx");
} else {
header("Location: linkherexxxxxxxxxxx");
}
?>

I am no coder either, but this is what I use and it gets the job done.


Perfect, just what I needed.

Thanks!
 
Code:
<?php

// Put a ' or a " around each url and a , after each one except 
// the last one
$urls = array(
  
  'http://www.yahoo.com',

  'http://www.wickedfire.com',

  'http://www.google.com/search?num=100&q=free%20porn'
 
);

$random = $urls[rand(0, count($urls)-1)];

header("Location: $random");

exit;

?>
 
Status
Not open for further replies.