.htaccess holding page and block website
Every once in a while i will get a request from one of our clients who will want a holding page put up instead of their current site. With this they usually don’t want any of the site accessible except for this holding page stating that changes will be coming soon and contact details or something along those lines. The easiest way for me to carry this out is by using a htaccess file to block access to everything except the holding page. Its alot easier than trying to edit every page on the site or deleting files because for all i know the customer may want it back exactly the way it was a few hours after i’ve done it. Heres the .htaccess code i use
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{REQUEST_URI} !^/holding.jpg [NC]
RewriteRule .* /index.php [L]
You may notice that you will need to include any images that are used in the holding page too as these are requested individually when the page is requested, so they need to be excluded from being blocked like so
RewriteCond %{REQUEST_URI} !^/holding.jpg [NC]
Depending on the situation your client may still want to see the old site while still blocking access to the rest of the public. You could put some kind of ip address blocking in place but as its for a client whos ip could change frequently we can move the entire site to a folder called “site” for example and then add an extra couple of lines to the htaccess file.
RewriteCond %{REQUEST_URI} !/site$ [NC]
RewriteCond %{REQUEST_URI} !/site/(.*) [NC]
You can then give the link to your client http://www.domainname.com/site and they will be able to see their old site. Anyone else with bookmarks or links to the old site will just be redirected to the holding page. Its only if they happen to guess that the site is under the site subdirectory will they be able to see it.
Comments
Comments are currently closed