If you’ve ever worked with cPanel and needed to deploy a new static site on your hosting account, you’ve likely encountered a familiar process that involves uploading a new site folder, deleting old files, copying the folder’s content to the root, and finally, cleaning up by deleting the empty folder. However, this approach comes with an undesirable side effect – downtime. The duration of this downtime varies depending on your site’s traffic, but it’s evident that this isn’t an ideal solution.
To address this issue, I’ve sought out a quick and flexible solution that allows you to upload multiple versions of your site and seamlessly switch between them without affecting the user’s URL.
The secret to achieving this lies within the .htaccess
file, and here’s how you can make it work. You’ll need to add the following information to the .htaccess
file located in your website’s root directory:
With this in place, every time you upload a new version of your static page and ensure everything is functioning as expected, all you need to do is change the folder’s name to which you want to point. Your domain will then automatically redirect traffic to the new folder, completely eliminating downtime while affording you the flexibility to roll back to a previous version if necessary.
This method not only prevents downtime but also offers a hassle-free way to manage and switch between different versions of your site, making it a reliable solution for deploying updates without inconveniencing your users.
What do you think? Is there any way to make it even better?