Home PHP JavaScript CSS WordPress APIs .htaccess Other How-To Useful Scripts What I Recommend
Posted on by Aleksandar Gichevski ()

Maintenance is important part from every website or system where you do regular coding updates or fixes.

In times like that it is nice to show to your visitors custom maintenance page where they will get information about the process and time-frame of execution.

With .htaccess you are able to create redirect to desired maintenance page with just few lines of code…

First create page called maintenance.html which will be custom page where your visitors will be redirected.

Then in your site .htaccess file add below lines:

Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteRule !maintenance.html$ http://www.yourdomain.com/maintenance.html [R=307,L]

And that’s it!...

But this is good only in cases when you move your site to another location and you don’t need access to it.

What if you want to redirect all visitors except yourself so u can work and preview the site in any time on its current location? Can that be done with .htaccess? The answer is YES!

In the above code between line 2 and 3 you add following:

RewriteCond %{REMOTE_ADDR} !000.000.000.000 [NC]

Replace 000.000.000.000 with your current IP Address and whalaa you gained access to the site and you can see it but all other visitors will be redirected to maintenance page.

Here is full .htaccess code how it should be:

Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !000.000.000.000 [NC]
RewriteRule !maintenance.html$ http://www.yourdomain.com/maintenance.html [R=307,L]

Other Posts You Might Like

Get a fast, free website audit


Enter your URL below to get full in-depth SEO report and tips.

Useful Scripts

Most Popular Posts

Recent Posts

June 14th, 2014
Website Optimization Using Gzip Compression

June 10th, 2014
Google Search AutoComplete API

May 14th, 2014
What is a Tag Cloud and How to Calculate it by Formula

March 27th, 2014
Error writing file /tmp (errcode 28) Solved!

February 15th, 2014
Fixed CSS & HTML Navigation Bar

February 9th, 2014
Benchmark Your Server (CPU, File IO, MySQL) with SysBench

February 8th, 2014
JavaScript Array Basics

January 29th, 2014
JVZoo IPN API in PHP

January 25th, 2014
Payoneer Debit Card for Freelancers to receive money online

January 24th, 2014
How HTML Color Codes are generated?

Read Latest Posts directly on Facebook

Archive