(+84) 463.28.7979

Redirecting Visitors to a Temporary Maintenance Page in WordPress without a Plugin

Yesterday, we showed you how to temporarily redirect your visitors to a maintenance page in WordPress using popular plugins. That method is great, but some developers prefer to get their hands dirty by going the non-plugin route. Well in this article, we will show you how to redirect visitors to a temporary maintenance page in WordPress without a plugin.

This post is part of a Series

Redirecting Visitors a Temporary Maintenance Page in WordPress with Maintenance Mode Plugin

Six Types of Maintenance Page Designs – Which One Works for You?

.htaccess Method

One method is via .htaccess that allows only single IP to access the site. This is a quick snippet for a single-developer project.

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule .* /maintenance.html [R=302,L]

Basically, all you would need to do is change the Remote_Address to your IP address. Then, you would need to create a page called maintenance.html, and style it to however you like. This should be stored in your root directory. The code basically lets you see the entire site, and everyone else gets the maintenance.html page.

If you want to allow multiple IP addresses, then use this technique:

 order deny,allow
 deny from all
 allow from 123.456.789
 allow from 123.456.789
ErrorDocument 403 /custom-message.html
<Files custom-message.html>
 order allow,deny
 allow from all

Simply add as many IP addresses you want to allow. Everyone else will get the page “custom-message.html”. You can add whatever you like in the custom file.

Honestly, we think by going the WordPress maintenance plugin route is a lot easier. Question to users: Why do you think the non-plugin route is better?

Note: Brad Williams in the comment pointed out that there is another method of doing this which is actually built-in with WordPress. Check out Matt “Sivel” Martz’s Series Post (1), (2), (3)


Perishable Press (1), (2)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>