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

Help! Need to have website redirect to 2 different places depending on time of day

Discussion in 'Cloaking and Content Generators' started by ppcgod, Dec 1, 2010.

  1. ppcgod

    ppcgod Registered Member

    Joined:
    Feb 18, 2009
    Messages:
    54
    Likes Received:
    32
    I have a domain that I want to redirect to site A between 7amEST-7pmEST and redirect conversely to site B from 7pm-7am. (hiding from someone lol) Right now I just have to log in and edit my meta refresh manually every day (gets quite annoying).
    Is there a script to make it change redirect automatically based on a server side timing? I tried to google it but it was confusing sorry I am a noob with html and php. LOL. Any tips greatly appreciated.
     
  2. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    There are plenty of different ways to skin this cat, but here is some php off the top of my head that you can play around with. Haven't tested it, but with a little tweaking you should be able to get this to work for what you need. Check out the PHP docs for the various date and time functions if you need to be more precise.
    PHP:
    <?php
    date_default_timezone_set
    ('EST');
    $currentTime idate('H');

    if (
    $currentTime >= && $currentTime <= 19)
    {
        
    header("Location: http://www.siteA.com/");
    }
    else 
    {
        
    header("Location: http://www.siteB.com/");
    }  
    ?>
    Cheers!
     
    • Thanks Thanks x 1
  3. ppcgod

    ppcgod Registered Member

    Joined:
    Feb 18, 2009
    Messages:
    54
    Likes Received:
    32
    Thanks grizz I got it up and running you saved my life <3
     
  4. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    glad to be of service :)