[Solved] How can I redirect my webpage in a specific order? [closed]


The main issue with this is you need info about the previous visitor.

For this, you need to keep track of what each visitor is redirected to, so the next one will have access to the info.

If you have only one webserver, this is easy.
Just create an empty file for odds visits, and delete it for even visits.

 // Untested code, just to give the general idea

$trackingFile="/usr/share/whatever/oddvisit";
if(file_exists($trackingFile)){
    // even visitor
    unlink($trackingFile);
    Header('Location: http://url2.com');
    exit;
}else{
    // odd visitor
    touch($trackingFile);
    Header('Location: http://url1.com');
    exit;
}

If you have multiple webservers, this is a little bit trickier.

If you have no NFS all your webservers can access, you can store the odd/even info in a database. But it’s best if you don’t have a huge amount of trafic.

If you have a lot trafic, I think the best solution would be to accept that each webservers will redirect visitors they get, independantly of what other webservers do. With very large numbers, you should get a pretty decent 50/50 redirections.

3

solved How can I redirect my webpage in a specific order? [closed]