Switch between old and new site

Permalink
Hello!

One of my clients wanted to have their old site up while the new one was being developed. Instead of having a development server and having to deal with migrating, I simply installed Concrete5 on the live server and made a simple redirecting trick.

The old website was built in Dreamweaver and consisted of only static html pages. Luckily all of the file references were relative, so it was easy to move the old site into a separate subfolder of the web root.

Concrete5 was installed on the root and set up with all contents and a custom designed theme.

For the redirecting I created a subfolder at root level called '_new', added a index.php which simply created a cookie and redirected to root.
setcookie('company_new_web', 'new_site', time()+360000000, '/');
header("Location: /");


On root level I also added a folder '_old', and added a index.php which reset the cookie.
setcookie('company_new_web', '', time()-60, '/');
header("Location: /");


The index.php on root had to be changed to check for the cookie and it's value. It didn't require a lot of changes. This was sufficient:
if (isset($_COOKIE['company_new_web'])) {
   if ($_COOKIE['company_new_web'] == 'new_site') {
      require('concrete/dispatcher.php');
   }
} else {
   header("Location: /old_site/");
}


It's a very simple trick and it might have been done better, more secure, simpler, I don't know. The most important for this trick was to make it easy and understandable for the client.

When the client goes to company.com, the index will check for a valid cookie and redirect according it's value. When going to company.com/_new/ a cookie is set and the user is redirected to the new site. Everything works as normal because the cookie check will always validate. The cookie can be reset by going to company.com/_old/.

 
ijessup replied on at Permalink Reply
ijessup
Very cool. I like the idea. Thanks for sharing!