Cloud, CMS, DevOps & Cloud Solutions, Uncategorized

Implementing maintenance mode for a Production Release

Steps to implement the maintenance mode on your website for Production release

In case of a production release, when the live sites have to be set up to display the “Maintenance mode” the below mentioned steps have to be followed. These have been exclusively applied for the websites hosted on AEM  and work perfectly fine for them.

1)Clear the dispatcher cache and fetch the maintenance page that has been created for your website.

  • rm -rf  <path where the cache gets created>
  • wget <>

2) Copy the maintenance.html page from /content/…… to the actual docroot of the dispatcher.

That is, if the maintenance page is actually present in the path /mnt/var/ww/html/content/site/maintenance.html

then this page has to be copied to the path – /mnt/var/ww/html

2)Create an empty file named maintenance.enable in the docroot (/mnt/var/www/html/publish)

  • vi /mnt/var/www/html/publish/maintenance.enable

This is the main file that tells the dispatcher that the maintenance mode has to be enabled.

3)Add the below lines to the conf file of the your site –

Open the .conf file using –

  • vi /etc/httpd/…../site.conf

and paste the below lines –

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f

RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f

RewriteCond %{SCRIPT_FILENAME} !maintenance.html

RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|png|css|js|woff|woff2)$ [NC]

RewriteRule ^.*$ /maintenance.html [R=503,L]

ErrorDocument 503 /maintenance.html

Header Set Cache-Control “max-age=0, no-store”

Header always set Retry-After “3600”

Explanation for this snippet :

This lets the website’s conf file know about the  maintenance.html and maintenance.enable files in the doc root.

Any request that reaches this file with any extension except for the ones given above (jpeg, gif, png, css, js, woff and woff2)

will be redirected to the maintenance page with a status 503. These extensions can be changed as per your requirement.

This status(503-maintenance) tells the website crawlers that the site is under maintenance and that they have to come back later (as per the Retry-After header).

This prevents the hampering of the SEO ratings of the site.

NOTE : If there are multiple websites that are being handled by a single dispatcher and you have separate maintenance pages for each one of them, displaying individual site’s maintenance page is also possible.

Copy any one of the maintenance page in the doc root and then have the individual maintenance pages cached in their own cache paths. This will enable the dispatcher to pick up the relevant maintenance page (site wise) and display them accordingly.

4) Server is restarted then in order to apply the changes. From now on, if the configurations are present in the server then, every time the maintenance.enable file is created in the docroot, the server goes into the maintenance mode and when it’s deleted it comes back to the normal mode without a restart.

To get back to the normal mode,  delete the maintenance.enable file from the docroot path ( /mnt/var/www/html)

5) In case if you do not want to retain these lines in the conf file then comment them and remove both the maintenance.html and maintenance.enable files from the doc root.

In this scenario, a restart will be needed the next time when you uncomment the lines in the conf file to implement the maintenance mode.

Also, again the maintenance.html and maintenance.enable  have to be made available in the doc root.

  • service httpd restart


About The Author

Leave a Reply