Redirect to maintenance page during upgrade using .htaccess

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can redirect your user to maintenance page easily by using .htaccess file.

So just follow the steps below to create a .htaccess file to redirect your visitor to maintenance page during upgrade:-

  1. Create a file and name it .htaccess with the content below:-

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.html$ 
    RewriteRule $ /maintenance.html [R=302,L]
    
  2. Once the file is created, put it at your root directory. (This will be in http://www.yourdomain.com/.htaccess)
  3. Create another file name it maintenance.html (just put what messeage you want to show to your visitor during the upgrade) and put it at the root directory too. (This will be in http://www.yourdomain.com/maintenance.html)
  4. Now you can try to browse your site and it should now redirect you to maintenance.html
  5. Since you are going to perform the upgrade, you have to able to browse the site. So you have to exclude your IP in the .htaccess file. Now you have to add a line in the .htaccess file as below:-

    RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
    

    ** Please change the fake ip (888.888.888.888) to your own IP, you can find out what your IP is by visiting our Support Centre
  6. Now your .htaccess file should look like below.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !/maintenance.html$
    RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
    RewriteRule $ /maintenance.html [R=302,L]
    

Your visitor should be redirected to maintenance page by the .htaccess we set just now and you should be able to browse your site and perform your upgrade.

  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How do I redirect parked domains to the main account domain using mod_rewrite?

Sometimes to protect your brand you will have several domains relating to one site however you...

How do I force my website to use/not use the "www" prefix?

To force all website visitors to use either user the www. part of the domain or not in the URL...

Can I use mod_rewrite?

Mod_rewrite is an Apache web server module installed on all of our web servers by default, all...

How do I force a redirect from http to https?

If you want to redirect your visitors to the secure version of your site, you can use the...

How do I redirect parked domains to the main account domain using mod_rewrite?

Sometimes to protect your brand you will have several domains relating to one site however you...