Quantcast
Channel: BloggingPro
Viewing all articles
Browse latest Browse all 30

How To Put Your Website In WordPress Maintenance Mode

$
0
0

No matter how careful you are with your website, itty-bitty problems might still find their way through the security cracks. Thankfully, your WordPress website has a so-called WordPress Maintenance Mode; this is similar to the safe mode in a Windows device. You can use it to make your website temporarily unavailable in the event that something goes inexplicably wrong with it.

Of course, WordPress maintenance mode prevents your visitors from accessing the website. It’s a small and temporary price to pay for both parties involved. Sometimes the damage can be worse than expected, however, and the visitors simply get a 404 or a similar error when accessing your site.

In that case, you might as well utilize WordPress maintenance mode so they get a friendly notice instead of the intimidating error. Afterward, you can work in the background to fix the problem. Here’s what you can do to get started:

1. Built-in maintenance tools

One of the quickest or simplest methods to enable your WordPress maintenance mode is through a built-in WordPress maintenance tool. However, the built-in maintenance tool for WordPress is quite limited and probably won’t help you fix some serious security issues or bugs. It only activates during WordPress core or plugin updates.

wordpress maintenance mode

Rest assured, you don’t need to manually enable WordPress maintenance mode when running a clean update of your WordPress site. This built-in function is facilitated by the .maintenance file located in your WordPress file directory. That means you have little to no control over this, just be careful with the said file. In any case, a WordPress update shouldn’t last more than an hour, the same goes for the automatic maintenance mode.

2. Maintenance mode through the .htaccess file

Now, if you want to manually access maintenance mode (which honestly, is a lot of work), then you’ll need full access to your server. Before that, however, you have to create your own maintenance.html page. This is where your visitors will be redirected. To do this, just look for any maintenance page HTML template online. Here are some stylish ones from Colorlib.com to save your time.

Now that the maintenance page is set-up, access your server; you’ll need to look for the .htaccess file. If you have trouble finding it, search for the root directory of your website, it’s usually there. Once you’ve found it, open the .htaccess file then copy and paste the following code at the bottom of the notes:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.123
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ https://example.com/maintenance.html [R=307,L]

Take note of the last part, as you’ll have to replace the “example.com” with the URL of the maintenance HTML page you created in. Also, take note of the %{REMOTE_ADDR} part as you’ll have to replace the displayed numbers there with your own IP address. This is important because it allows you access to your site under maintenance mode no matter what, so don’t skip it.

Once you’ve done that, any unauthorized incoming traffic or request to your website will then be redirected to the maintenance HTML page. Voila! You’ve done some programming magic.

3. Maintenance mode plugins

Manual method a little too tedious for you? Understandable, not all of us are wizards, after all. If you want to do away with the lengthy .htaccess file method, you can opt to use some WordPress maintenance mode plugins instead. These do the task automatically and even let you design some beautiful splash pages for the visitors.

wordpress maintenance mode

A quick trip to WordPress’ maintenance mode plugins page ought to do the trick. You’ll find some of the most popular maintenance mode plugins on that page. If you’re looking for one of the best, however, you might need to opt for the premium ones, SeedProd comes to mind but you can stick to free maintenance mode plugins as well.

4. Force maintenance mode with a splash page

wordpress maintenance mode

Here’s a neat and easier trick: you can actually redirect your visitors or any request for your website into a maintenance splash page without manually going into maintenance mode first or using a plugin. You’re then free to do any fix or update to your website without any external interruptions. All you need to do is look for the functions.php file usually located in your WordPress themes folder.

Open the file and add these codes:

// Activate WordPress Maintenance Mode
function wp_maintenance_mode() {
    if (!current_user_can('edit_themes') || !is_user_logged_in()) {
        wp_die('<h1>Under Maintenance</h1><br />Something ain't right, but we're working on it! Check back later.');
    }
}
add_action('get_header', 'wp_maintenance_mode');

Essentially, this forces maintenance mode on your WordPress site. A message that your site is under maintenance is also displayed. You can edit that message by changing what comes after the H1 tag in the code. The friendlier the better, of course!

RELATED: Best Content Management Systems in 2019

Maintenance mode tweaks:

Controlling website access

Often when you initiate maintenance mode, any user with login access will still be able to view the site’s dashboard and other functions. However, the same cannot be said for regular website visitors who are also members of the site– that is assuming you run a form of website membership which is quite common in vendor sites.

If you want to be selective with which visitors to allow in during maintenance mode, you’ll have to use a plugin which allows it. Coming Soon Page and Maintenance Mode by SeedProd can offer such a capability for free. You also might want to check other plugins with what types of WordPress users and roles they allow during maintenance mode, in case you want full control over the tool.

Selective maintenance mode

Similarly, you might also want the option to make some pages available during maintenance mode. This allows visitors to still view and use your website while you seal off and work on the parts that need attention. For this, you’ll want to exclude specific pages and parts of your WordPress maintenance mode using the versatility offered again, by a maintenance mode plugin.

You’ll naturally want a plugin that lets you do that. Simply check their maintenance mode coverage in their respective websites or pages. This is the easiest way to do it and you’ll never want to go back to coding this function as it’s prone to errors. Regardless, you should now be well-equipped with new knowledge on running a WordPress maintenance mode.

RELATED: I Love that WordPress Plugin – WP Maintenance Mode

 


Viewing all articles
Browse latest Browse all 30

Latest Images

Trending Articles





Latest Images