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 ;-)