I am a System Administrator trying to host a small website in my private time. As a start I am using Wordpress.
Currently I am trying to achieve that when someone presses a link, he/she gets redirected to a random page.
This should be easy as my pages are something like website.com/network1 , website.com/network2 etc. In this case I want to create a function that generates a number and replaces the number. So in this case it would look like website.com/network$random_number.
I've tried Googling this and I've found a script that should do exactly this: Going to a Random page PHP Funny thing is that it's on the same website!
Unfortunately when using this code in a file called 'random.php' located in ./dump/ it will result in being redirected to: /random.phpdump/random.phpdump/random.phpdump/random.php (so a loop).
The code I am currently using is:
<?php
//from http://php.net/header
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$random_number = rand(1,5);
header( 'Location: https://website.com/network$random_number', true /* overwrite */, 303 );
?>
How can I change this to get it working and what am I doing wrong?
Thank you in advance!