Hosting Question? Find the Solution -

KNOWNHOST KNOWLEDGE BASE

Browse our Guides, Articles, and How-To's

Preventing Updates to Websites

Category: Getting Started
Tags: # # # # # # # # #

If you wish to ensure no changes are being made to websites during a migration, it is best to consider preventing updates on your website and setup some form of maintenance or offline mode. Many CMS applications offer this functionality through use of plugins or a .maintenance file in the document root. By placing the website in maintenance mode prior to a migration, this helps to ensure there will not be any changes made while the data is being copied, or in the time between the data copy and DNS updates. This can be very helpful when dealing with busy forums, blogs, and ecommerce websites. Included below are some general guidelines for placing common CMS applications into maintenance mode for a migration. For specific questions about various applications, we recommend consulting the documentation for the apps or with a developer who is familiar with the application.

Manual or Generic Maintenance Mode

The following instructions can be used for most applications, but if there are specific guidelines for the application in the list of applications further below on the page, we recommend using the method that is easiest for you or your users. For applications that do not publish documentation on enabling maintenance mode, it is possible to configure maintenance mode manually with some simple .htaccess rules and html or php pages. The .htaccess file can be set up to rewrite all requests to a specific maintenance page, with a 503 response code. Specific IP addresses can be added to bypass the redirect rule.

First, create a maintenance page. For the purposes of this example we will use a file called “maintenancepage.html”

<!DOCTYPE html>
<html>
<body>
<h1>Under Maintenance</h1>
<p>This website is undergoing temporary maintenance. Please try visiting again later.</p>
</body>
</html>

We place the file in the document root of the website, then add a block to the top of the website’s .htaccess file. If the .htaccess file does not exist, it can be created. The following code will redirect all visitors who do not have an IP address of 123.123.123.123 to the maintenance page. You can replace this IP with your public-facing IP address to allow your devices to bypass the maintenance page.

# Enable maintenance mode
 ErrorDocument 503 /maintenancepage.html
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_URI} !=/maintenancepage.html
 RewriteCond %{REMOTE_ADDR} !=123.123.123.123
 RewriteRule ^.*$ - [R=503,L]
 </IfModule>
# End Enable maintenance mode
WordPress

WordPress offers several plugins which can provide options for deploying a “maintenance” or “coming soon” page. WordPress core code does define a .maintenance file that can be placed in the document root of the website, but the core code generally will ignore this file if it is older than 10 minutes. There is a wp-cli command that can be used to enable maintenance mode via the .maintenance file. This will display a simple maintenance message to anyone visiting the site, and a 503 “Service Temporarily Unavailable” response code, instead of displaying website content.

Briefly unavailable for scheduled maintenance. Check back in a minute.

A typical .maintenance file might have contents similar to the example below, where the value in the upgrading variable is listed in epoch time.

<?php $upgrading = 1609459200; ?>

If the .maintenance file is intended to be used for longer than 10 minutes, then it is possible to use a workaround to keep the website in maintenance indefinitely.

<?php $upgrading = time(); ?>

This is a workaround and not an officially supported or recommended procedure however. After the migration is complete, the .maintenance file or the maintenance mode plugin can be removed on the destination server.

Xenforo

Xenforo offers an option to close the forums which is detailed in their official manual. To close the forums, use the “Board Active” option in the admin area, under Setup → Options. Visitors will not be able to view or post any content while the board is not active. The board can be reopened on the destination server once the migration is complete.

WHMCS

Within the General Settings of the administration portal (Configuration → System Settings → General Settings) it is possible to enable Maintenance Mode as well as a Maintenance Mode Message. While this is configured, customers are prevented from accessing the Client Area and the Maintenance Message will be displayed. This can be disabled on the destination server after the migration is complete.

Magento

Magento 1.X installations can be placed into maintenance mode with an empty .maintenance file in the document root where Magento is installed. Magento 2 can use a .maintenance file inside the var/ directory, or can use bin/magento maintenance:enable over CLI (please ensure commands are run using the user account containing the installation, and not as root). This can be disabled by removing the file or running bin/magento maintenance:disable over CLI. More details can be found in the Magento documentation.

Moodle

Maintenance mode can be enabled or disabled in the admin area under Administration → Site administration → Server → Maintenance. Maintenance mode will prevent any users other than administrators from using the site while maintenance is taking place. More information can be found in the Moodle documentation.

Prestashop

Prestashop has a toggle in the admin portal under Configure → Site Parameters → General titled “Enable Shop” which will place the site in maintenance mode if set to No. Optionally it is possible to allow certain IP addresses to bypass the maintenance mode, or enter maintenance text to display to visitors while the website is under maintenance. More details can be found in the Prestashop documentation.

vBulletin

Maintenance mode can be enabled in vBulletin’s admin portal and is located under Settings → Options. The “Forum Active” setting can be found in the “Turn your vBulletin On and Off” section as outlined in the vBulletin documentation.

Joomla

Joomla’s maintenance mode can be toggled on or off either in the Admin → Site → Global Configuration menu for Joomla 2.5, or Admin → System → Global Configuration menu in Joomla 3.X. There are additional optional settings, such as Offline Message, which are detailed in the Joomla documentation.

Drupal

In the admin interface under the Manage menu, Mantenance Mode as well as a maintenance message can be togggled at Configuration → Development → Maintenance mode (admin/config/development/maintenance). For more details, see the Drupal documentation

Laravel

Maintenance mode can be enabled for Laravel applications by executing the following command: php artisan down (please ensure commands are run using the user account containing the installation, and not as root). Maintenance mode can be disabled by running the comand php artisan up. For more information, see the Laravel documentation.