Random index site
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
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
Or you can include this index<n> pages in index.php without redirecting.
Let me try, if it really works..
Do you have any interpretator on server?
In PHP you could do something like:
header( 'Location: http://www.yoursite.com/index'.$i.'.html' ) ;
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'.
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?
Thnx Luno for this help. i will definitely back soon if this will work for my sites. :)
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.
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.)
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...
"There's more than one way to do it" (r) :)
It possible make also without PHP - with using JS.