Redirect a php page to multiple random links in php

create go.php

<?php
    $urls = array('/wordpress-hosting',"vps-hosting","magento-hosting"); //specify array of possible URLs
    $rand = rand(0,count($urls)-1); //get random number between 0 and array length
    $location = $urls[$rand]; //get random item from array
    header ('Location: '.$location);
?>
 

<?php
$addresses = [
    'http://www.google.com',
    'http://www.facebook.com',
    'http://www.youtube.com'
];
$size = count($addresses);
$randomIndex = rand(0, $size - 1);
$randomUrl = $addresses[$randomIndex];
?>


<a href="<?php echo $randomUrl; ?>">random url</a>

<script type=”text/javascript”>

var urls = new Array();
urls[0] = “http://learninginhand.com”;
urls[1] = “http://learninginhand.com/about”;
urls[2] = “http://learninginhand.com/contact”;
urls[4] = “http://learninginhand.com/services”;
urls[5] = “http://learninginhand.com/videos”;
urls[6] = “http://learninginhand.com/infographics”;
urls[7] = “http://learninginhand.com/resources”;
urls[8] = “http://learninginhand.com/stickaround”;
urls[9] = “http://learninginhand.com/posts”;
urls[10] = “http://learninginhand.com/pet”;

var random = Math.floor(Math.random()*urls.length);

window.location = urls[random];

</script>

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat