My company is going to do a press release next month. At that exact moment in time, we need a new domain to go to this site at the time of the press release at 3 PM.

Since the domain name already exists, my plan was to have an index.html and index.php in the root directory of the web server. index.html would redirect to our current website and index.php would have the page for our new site (under the separate domain name). My plan was at 2:59 PM I would rename the index.html file so that index.php would be the only index file on the server, and requests going to www.example.com wouldn't redirect anymore but instead stay on the new site.

Is there a more efficient way of ensuring this? This is an Apache 2 server running PHP 5.3 and MySQL 5.5

2 Answers 2


You could just include a rule in your index.php to check the current time against the time you want to launch. So if you wanted to launch on 2015-12-01 at 15:00UTC, something like this should work:

<?php if(time() < '1448982000'){
  header("Location: https://www.example.com/",TRUE,301);

Drop that into the very top of index.php and adjust accordingly.

  • I'll try it out on the staging server. Actually my description was a little weak. What I need is the opposite, but I change that with the < instead of >. I need to forward UNTIL a certain time, then stop forwarding.
    – Tensigh
    Commented Nov 20, 2015 at 10:11
  • Updated to reflect that. Commented Nov 20, 2015 at 10:35

It's really risky solution. Some browser (or ISPs) can cache index.html. After refreshing page, some users can find some troubles there.

I believe much better solution will be using only one .php file as a routing file, which will detect time and do different things on these time frames.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.