I need help with a redirect script. Basically, I need to redirect the user to a random page which then requires the referer (which will be the redirect page). The problem is the redirect method I'm using doesn't carry the referer. I did manage to use an alternative Javascript redirect which carried the referer but it didn't work on Firefox! Here's the code from REF.PHP <?php srand ((double) microtime() * 1000000); $ref = array("/affiliate-marketing-basics.php","/affiliate-marketing-leads.php","/affiliate-markets-saturation.php","/article-marketing-to-help-in-affiliate-marketing.php","/tracking-affiliate-referrals.php","/web-hosting-affiliate-programs.php"); $rand_url = array_rand($ref,6); $url = $ref[$rand_url[0]]; echo('<meta http-equiv="refresh" content="0;url='.$url.'">'); ?> Code (markup): Any help would be much appreciated.
Is there some reason you can't do a standard redirect: srand ((double) microtime() * 1000000); $ref = array("/affiliate-marketing-basics.php","/affiliate-marketing-leads.php","/affiliate-markets-saturation.php","/article-marketing-to-help-in-affiliate-marketing.php","/tracking-affiliate-referrals.php","/web-hosting-affiliate-programs.php"); $rand_url = array_rand($ref,6); $url = $ref[$rand_url[0]]; header("HTTP/1.1 301 Moved Permanently"); header("Location: mysite.com/".$url); exit(); PHP:
One of yours problems you might run into is that the user's browser won't pass the referer part of the header which makes that part of the script use less what you might want to do is pass a GET variable with the page it came from somehow.
Just a small addition: instead of this you could use only one line with http response code specified header("Location: mysite.com/".$url, true, 301); PHP: and PHP will do the rest.