如何实现"维护模式"对已经建立的网站 [英] How to implement "Maintenance Mode" on already established website
问题描述
我建立了一个网站(PHP)超过60页。只是现在我已经意识到(不幸的),我应该已经建立了一个维护模式功能,让管理员暂时禁用该网站,它指向一个维护模式页面。这样做只会让那些身份登录,管理员可以查看该网站。
I have built a website (PHP) with more than 60 pages. I have only now realized (unfortunately) that I should have built in an "In Maintenance Mode" feature to allow an admin to temporarily disable the website and point it to a Maintenance Mode page. This would only allow those logged in as an admin to view the website.
我看到的选项有:
-
添加一个新的包含文件的每一个PHP页面的顶部。
Add a new "include" file to the top of every single PHP page.
我有一个包括用于显示在
导航栏
每一页(导航类)。我可以写的维护模式
code在这个类。
I have one include that is used to display the navigation bar on
every page (navigation class). I could write the Maintenance Mode
code in this class.
难道我有什么其他选择?似乎是第一个选项并不像最有效的,而第二个刚刚好像不好的编程。有没有其他更好的办法,包括对每一个php文件的新文件?
Do I have any other options? The 1st option doesn't seem like the most efficient, and the 2nd one just seems like bad programming. Is there any other better way to include a new file on every single php file?
谢谢!
PS - 该网站未启动尚未
ps - the site is not launched yet
推荐答案
您可以使用的.htaccess
来重定向到另一个页面,而在维护模式。
You can use .htaccess
to redirect to another page while on Maintenance Mode.
三配套的例子:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^11\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://domain.com/maintenance.html [R=307,L]
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ /maintenance.html [R=302,L]
<一个href="http://www.techiecorner.com/97/redirect-to-maintenance-page-during-upgrade-using-htaccess/">Redirect使用的.htaccess 升级过程中的维护页
Redirect to maintenance page during upgrade using .htaccess
# redirect all visitors to alternate site but retain full access for you
ErrorDocument 403 http://www.alternate-site.com
Order deny,allow
Deny from all
Allow from 99.88.77.66
这篇关于如何实现&QUOT;维护模式&QUOT;对已经建立的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!