How to put site in construction mode quick and easy via .htaccess

///How to put site in construction mode quick and easy via .htaccess

How to put site in construction mode quick and easy via .htaccess

Do you run a blog like wordpress or some other CMS driven website? Or even a MVC like CakePHP or Codeigniter? Something that in essense runs solely off of index.php for the most part? Sure why not. Most sites now a days run off of a lone php file. So. A quick easy way to get your site into a maintenance or construction mode is to alter your .htaccess file by adding the next line to it (above everything else in there already).\r\n\r\n
DirectoryIndex underconst.html index.php index.html index.htm
\r\n\r\nWhat this one line does is pretty much tells your Apache driven server (or other like server that supports .htaccess (most do, but the ones that don’t have a similar directive somewhere). Is that you want to serve these files in order each one taking precedence over the other. So in this case I can have 3 index files in the same directory and only one of them will be seen (unless you point your browser directly at it) so the line above says php is first in line, then html, then htm. But theres one more specific file before them all underconst.html you can name it whatever you like really. But if this file is found in the same directory as the .htaccess file, this file is going to be served first and foremost.\r\n\r\nNow why is this handy. Easy, lets say something goes seriously wrong with your site and you need to fix it. But you want to shut others out that come to the site while in the mode (Note this does not cover all the bases of booting everyone off but its a good start, pending how you have your entire site built up). \r\n\r\nAnyway just wanted to offer that tasty nugget of useless wisdom.
By |2014-01-05T10:21:58+00:00March 16th, 2012|Code, htaccess|0 Comments

About the Author:

Not much to know about me, I'm a 35+ year old coder, geek, gamer..

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: