Is it possible to open a random index site when someone visit my domain?
For example I have index1, index2, index3 and so on. And now I want every time someone visit my homepage that he will be redirected randomly to one of those sites. Is there a way to realize this?
Thank you very much in advance
12-21-2012, 07:35 AM
Yes of course. What language do you want to do it in?
Basically the first thing the page's controller would do is get a random number from 1 to 3 (or however many pages you have the option of), and then redirect to '/index'.$randomNumber by setting a redirect header
12-27-2012, 01:15 PM
Or you can include this index<n> pages in index.php without redirecting.
This allows for 10 index files: index0.html to index9.html. It is not strictly random, as it increments at one second intervals from 0 to 9 then back to 0.
Note: That code MUST be at the very start of the file, which MUST be named '.php', E.g. 'index.php'.
12-30-2012, 04:10 PM
But for what we need redirect?
We need to send page for user only, so we can use:
instead of headers.
I think that we needn't generate excess traffic?
12-31-2012, 01:16 AM
Thnx Luno for this help. i will definitely back soon if this will work for my sites. :)
12-31-2012, 06:34 AM
Good point Luno, I should have thought of that, 'cos I routinely use include files, just not on a "random" basis. Though I'm not sure of the effect on search rating bots of a variable home page, either way??? By the way, if you do substitute include() for header(), remember to remove the exit command as well. That is only needed by the header() command.
12-31-2012, 06:42 AM
But with redirecting we will have the same situation when index.php will empty for search bots.
It will index index<n> file only.
If pages have one theme only, we can have index<n> files with BODY of pages only. So we will send header by index.php page (like desctiption, title etc.)
12-31-2012, 07:26 AM
Yes, I was thinking along those lines. You only need to include the variable content, which is the opposite of what I use include files for: I include the standard content (headers, footers, sidebar etc...) to minimise the maintenance of the site. Update an include file, and every page that uses it changes. Indeed, in this case there is no reason not to do both, i.e. use include files for standard and variable content...
12-31-2012, 09:40 AM
"There's more than one way to do it" (r) :)
It possible make also without PHP - with using JS.