tags:

views:

37

answers:

2

Hi from time to time , i want to shutdown my site for maintenance ...

How could i do this? I've seen a option in phpbb to block the site by admin and then unblock them..

Is there any apis for this or tell me a method of how to do this?

I'm using php for my website..

+5  A: 

I generally use a .htaccess file that contains something like this :

RewriteCond %{REMOTE_ADDR} !=MY_IP_ADDRESS
RewriteRule    ^$  /down.html  [L]
RewriteCond %{REMOTE_ADDR} !=MY_IP_ADDRESS
RewriteRule    [^/down.html$]  /down.html  [L]


Nice things with this idea are :

  • No PHP code involved -- which means I can totally do whatever I want with my PHP application, totally deleting it and re-uploading it, for instance, without any problem
  • I can test the website from one IP address (replacing MY_IP_ADDRESS by my real IP address), while everyone else will see the content of down.html

Once the maintenance operation is finished, I just comment those 4 lines, and voila, the website is re-opened ;-)

Pascal MARTIN
My ip address will be a dynamic ip.. so will that affect me at any point of time?
kvijayhari
If your maintenance operation only last for a couple of minutes, your IP address probably won't change during that time, will it ? *(I'm sometimes using a dynamic IP, and never had that problem)*
Pascal MARTIN
My operation may go upto 4 or 5 hours , and in that time if my internet connection is reset or my dynamic ip is changed someway , what could i do? Then can i access my site .. I'm asking in curiosity
kvijayhari
If your IP address changes, you won't be able to access your website ;; but changing the IP adresse in the .htaccess file will allow you to re-access you site, with your new IP ;-) *(And you probably won't change of address 10 times in 5 hours ^^ )*
Pascal MARTIN
A: 

You can use an .htaccess/mod_rewrite rule to redirect all page requests to a 'Temporarily Down' page.

Ted