Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

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

Last updated on by
Follow WPBeginner on YouTube
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.

# MAINTENANCE-PAGE REDIRECT
<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]
</IfModule>

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:

<Limit GET POST PUT>
 order deny,allow
 deny from all
 allow from 123.456.789
 allow from 123.456.789
</LIMIT>
ErrorDocument 403 /custom-message.html
<Files custom-message.html>
 order allow,deny
 allow from all
</Files>

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)

Sources

Perishable Press (1), (2)


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • Dave

    “Why do you think the non-plugin route is better?”

    For me personally, the non-plugin route gives me two things. One less plugin to integrate into what is largely a custom coded site, so no thinking of problems along plugin conflicts. The other reason is simply that I like .htaccess controlling the show. Assuming the .htaccess code works (in any situation), one doesn’t worry about 3rd party code. I know .htaccess isn’t doing anything other than controlling access. It’s also easy to test, regardless of one’s login situation. Just change the allowed IP to something random.

  • jaffa

    I am using the second example code above but how do you allow images to be displayed on the maintenance page?

  • http://gregoirelemaire.fr/wordpress/ Grégoire Lemaire

    hi and thanks for this tut! i recommend the nasty plugin : coming soon page which does the same but allow you customizing from back office parameters , great time unwasted !

  • http://webdevstudios.com Brad Williams

    I like the built-in maintenance mode that WordPress features. Most people don’t know about it, but Matt “Sivel” Martz wrote a great series of posts explaining it:

    http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/
    http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin-part-2/
    http://sivel.net/2009/10/wordpress-maintenance-mode-without-a-plugin-part-3/

    • http://www.wpbeginner.com Editorial Staff

      That’s really neat Brad. Didn’t know about it. Let me upgrade the article real quick.

  • http://iamzachreed.com/ Zach Reed

    I love not having to user plugins all the time for everything. I really like this method.

    A HUGE plus to doing it this way also is that is allows you to view the site without HAVING to be logged in (since it is by ip.) So now you can test features that may or may not exist when logged in verse logged out.

    For example if you had a special members only area that had special “logged in” features, you could test stuff without ALWAYS seeing those, like you would if you used a plugin and were logged in the admin.

    Great post!