1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect traffic between three different pages?

Discussion in 'PHP & Perl' started by dre2027, Mar 1, 2009.

  1. dre2027

    dre2027 Newbie

    Joined:
    Jul 21, 2008
    Messages:
    13
    Likes Received:
    0
    Is there a way to redirect/cycle traffic between three different pages?

    I mean, traffic comes in to a redirect script [index.php] then script...
    - sends the first visitor to page-a.php
    - sends the next visitor to page-b.php
    - sends the next visitor to page-c.php

    ...and then starts the cycle over by sending the next visitor to the top of the sequence at page-a ... and continues cycling indefinitely, for as long as visitors continue showing up.

    I know if it were just one page i wanted to redirect someone to I'd use basic php redirect:

    ?php
    header( 'Location: h**t*t*p*:*//*xxx.*yoursite.*xxx/*new_page.html' ) ;
    ?

    ...but to cycle through three different pages evenly I have no clue.

    There used to be a free app called "split test generator" [i think that was its name] that used to do this cycling but the script was faulty after just three visitors -- lol -- and was not worth the hassles of installing. The site is now long dead.

    Anyhow, if there is a script or bit of php code available that can cycle visitors evenly among three different landing pages please please please let me know.

    Thanks.

    Oh. Sorry about slaughtering the fake url. I haven't made 15 posts yet, so the script here wouldn't let me post that fake link in my post. I had to obfuscate the fake link somewhat to get this posted. Thanks for the help.
     
  2. Sweetfunny

    Sweetfunny Jr. VIP Jr. VIP Premium Member

    Joined:
    Jul 13, 2008
    Messages:
    1,747
    Likes Received:
    5,039
    Location:
    ScrapeBox v2.0
    Home Page:
    • Thanks Thanks x 1
  3. JonesersRX7

    JonesersRX7 Regular Member

    Joined:
    Mar 24, 2009
    Messages:
    201
    Likes Received:
    154
    This is EXACTLY what I was looking for - now if I could only get this to work with Brad's plug-in. Thanks again SweetFunny
     
  4. aReJay

    aReJay Power Member

    Joined:
    Apr 29, 2009
    Messages:
    736
    Likes Received:
    237
    Location:
    Down under
    Try This

    PHP:
    <?
    //Replace first,second,third with your required urls
    //You can add more urls if you like, just follow the template:
    //$url[x] = 'some url'

    $url[0] = 'First Url';
    $url[1] = 'Second Url';
    $url[2] = 'Third Url';

    //Select a random url and redirect to it
    header('Location:'.array_rand($url));
    ?>
    aReJay