728x90 AdSpace

  • Latest News

    Powered by Blogger.
    Wednesday 11 December 2013

    How To Put WordPress Site Into Maintenance Mode

    Sometimes, you may have the need to put your website into maintenance mode for upgrades. This would make your website temporarily unavailable to public access. You wouldn’t want errors to pop up when you are running important updates in the background, right?


    (Image credit: Aditya)
    There are several ways of putting a website into maintenance mode, and the technical details may differ accordingly. If you are on WordPress, here are 3 ways to put your website into maintenance mode.

    Using .Htaccess

    If you are using the Apache server, you can use.htaccess to control access of the directories within the server, and send a response code of the server status.
    To put the website into maintenance mode, you can use the 503 status code, which indicates that the server is temporarily unavailable.
    Before we specify anything in .htaccess, however, we need to create a new file in.html or .phpformat, and add a message in the file, e.g.
    Sorry we are down for maintenance, but we’ll be back up shortly.
    Style your page. Next, open the .htaccess file in your server, and add the following:
    1. <IfModule mod_rewrite.c>  
    2. RewriteEngine on  
    3. RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000  
    4. RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]  
    5. RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]  
    6. RewriteRule .* /maintenance.html [R=503,L]  
    7. </IfModule>  
    This will set the server status code to 503, while also redirects visitors to the maintenance page. You can set your IP address with the following line RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000 so that you will still be able to access your website.

    WordPress Built-In Maintenance Page

    When updating WordPress, plugins, or themes, you can create a file called .maintenance that says
    Briefly unavailable for scheduled maintenance. Check back in a minute.
    This file will be automatically removed when the process is completed – if the process fails, the file could get stuck in your server, so you have to remove it manually.
    The problem is that .maintenance is not customizable, as it is generated dynamically.
    So, if your emphasis is on the overall appearance of your website, you can create a file namedmaintenance.php, which you can customize with CSS, then put inside thewp-content folder. That way, the next time you update WordPress or plugins, WordPress will use the content inside this file.
    The function is specfied in wp-includes/load.php, like so.
    1. if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {  
    2.     require_once( WP_CONTENT_DIR . '/maintenance.php' );  
    3.     die();  
    4. }  

    Using A Plugin

    There are several WordPress plugins available to help put your website into maintenance mode, but my personal favorite is the Maintenance Mode plugin by Michael Wohrer. Although this plugin hasn’t been updated for about 2 years now, it still works perfectly.
    Using the Maintenance Mode plugin, you can simply activate or deactivate the maintenance mode with a few clicks. You can also specify how long the website will be in maintenance mode.
    In addition, this plugin comes with a default theme template to be displayed when the maintenance mode is activated. You can also use your own theme by creating a 503.php file and uploading it to your theme directory. Just go to the Maintenance Mode Setting page and select the 503.php file you have created.
    Here is a sample page where I used this plugin along with a 503.php page template.

    Conclusion

    We hope you found this tutorial useful in helping you run your WordPress site more efficiently. For further reading on the subject, you can head over to the following sites.
    • Blogger Comments
    • Facebook Comments

    2 comments:

    1. This comment has been removed by the author.

      ReplyDelete
    2. I like your post, its very knowledgeable for me to read these steps of put WordPress site into maintenance mode
      https://goo.gl/8jnL4n

      ReplyDelete

    Item Reviewed: How To Put WordPress Site Into Maintenance Mode Rating: 5 Reviewed By: Sandgun Cypher
    Scroll to Top