How to Redirect Visitors to Maintenance Page Using .htaccess

Sometimes, you may want to put your site into maintenance mode so that you can do required up-dates like modifying themes, including custom features, repairing corrupted files.

In this article you will find how to redirect all traffic and all visitors of your site to a maintenance page during site updates.

Create a Simple Maintenance Page

You first need to create a simple maintenance page with HTML into your root directory.

Create a new file named maintenance.html

Now open the newly created file and place the below code in it.

<!doctype html>

<html lang="en">


  <meta charset="utf-8">

  <title>Under Maintenance - Check Back Later</title>

  <meta name="description" content="Under Maintenance - Check Back Later">

  <meta name="author" content="Vamsi">

  <link href='//' rel='stylesheet' type='text/css'>


     html {

      background: #f1f1f1;


     body {

      background: #fff;

      max-width: 70%;

      font-family: "Open Sans", sans-serif;

      font-size: 14px;

      padding: 1.5em 2em;

      margin: 5em auto;

      -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13);

      box-shadow: 0 1px 3px rgba(0,0,0,0.13);



  <!--[if lt IE 9]>

  <script src=""></script>




  <h1>Under Maintenance - Check Back Later</h1>

  <p>We are performing some updates and maintenance tasks.</p>

  <p>Please check back later.</>



Once done save and close the file.

After uploading the file, you would be able to access the HTML file using the URL

Add .htaccess Rule

Now, open the .htaccess file in the root directory, copy the below code and paste it in the file. Save it and upload the file again.

# Redirect Visitors to Maintenance Page

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REMOTE_ADDR} !^192\.168\.100\.100

RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]

RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]

RewriteRule .* /maintenance.html [R=302,L]


Make sure to change the IP address in line 4 to match your current IP address.

Now all your site visitors will be redirected to the maintenance page. But you can still access your site as we’ve white listed your current IP address.

If you want to take away the maintenance mode, just remove the code you’ve added to the .htaccess file and you are good to go.

That’s all.