Automatic ReDirect

Discussion in 'Web Design and Development' started by JackT06, Mar 17, 2011.

  1. JackT06 macrumors 6502

    JackT06

    Joined:
    Jul 24, 2009
    #1
    Hello,

    Does anyone know a way that i can make my website redirect users to a specific page, BUT i can set a time when the redirect will automatically disable....

    The plan is that we need to do some major updates to our website, and then make sure people don't see them till 11 o'clock, BUT, no-one is around to disable the redirect, so we need it to work automatically....

    HELP!:(
     
  2. Laird Knox macrumors 68000

    Joined:
    Jun 18, 2010
    #2
    Looks like somebody will be staying late. ;)

    Seriously the best way to do a one-off like this is to have somebody stay and make the change.

    Otherwise you should be able to setup your web server to handle a timed redirect.

    Or you can trigger a script at the top of the page that redirects based on time.

    I wouldn't really recomend either but it is possible.
     
  3. nicksoper macrumors member

    nicksoper

    Joined:
    Mar 6, 2006
    Location:
    Cape Town
    #3
    This should help

    Hey bud, this should help if you are using PHP and don't mind the browser doing the redirect. If you don't want the server to physically serve the page until a specific date you will need to look at .htaccess files

    Otherwise this should help


    Code:
    <?php
    $date_var = date("ymdHis", time());
    
    // The date is formatted in year month day hour minute second.
    // eg. 13:01:50 on the 3rd of March 2011 will be 20110303130150
    // Simply choose the date and time you want the redirect to finish
    // Remember the time set on your server might be different to your local machine
    // Change <= to >= to output the html before the date you have chosen
    
    if($date_var <= "110318092415"){ ?>
    	
    <meta http-equiv="refresh" content="0;url=http://example.com/" />
    
    <?php } ?>
     

Share This Page