On 23rd February I took a number of sites offline to participate in the internet blackout in protest against New Zealand copyright law. This raised an issue though - how to take a site down and replace it with one page, without changing the site itself.
With a static HTML site, you can simply backup your index.html and replace it with the temporary page. Users will still see the other pages of your site though. If you are using a CMS or blog, the solution is not quite that easy. Most dynamic web applications have an index.php file at the root that is instrumental in loading all pages of the site. Replacing this with a temporary file can lead to server errors being returned if anyone follows a backlink to the site.
What we want is to make sure all traffic ends up on the temporary page. The solution is not difficult and since it worked so well for me on a number of sites I thought I would share.
- Create your temporary file and name it index.html
- Upload this to your server
- Edit the .htaccess file in your document root and comment out any URL rewriting by adding a hash to the start of each line
eg.<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] </IfModule> - Now, redirect all traffic to the temporary index.html page
RewriteRule !^index\.html$ /index.html [L,R=302]
This rule says that if the request is not for the index.html page, then send traffic to it.
That's it! Your CMS or WordPress install is not touched but your site is effectively taken down with only the temporary page accessible. When you no longer require the temporary page, simply delete index.html from your CMS or blog site (or replace it with the original if your site uses static HTML) and revert the changes you made to your .htaccess file.
If you enjoyed this post, make sure you subscribe to my RSS feed!














{ 3 comments… read them below or jump to the comment form to add your thoughts }
Excellent Web Site! Very professional and full of great information. I am greatly enjoying it. Your enthusiasm is wonderful!!!
I just wanted to say WOW! your site is really good and i'm proud to be one of your surfers
Thank you. I'm glad you are finding it useful.
Leave a Comment