开发者

I want a feature to temporarly block my website from accessing?

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 th开发者_如何学Pythone 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..


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜