.htaccess自动重定向到维护页面

时间:2013-07-24 14:59:01

标签: html .htaccess

我想知道是否在.htaccess文件中我可以查看网站是否已关闭。我发现了一些会将其重定向到维护模式的东西,但我不想每次都进去添加它。我有一个脚本,可以从存储库运行和更新我的实时站点。有没有办法检测此更新并自动将网站置于维护模式?

#This will redirect the site to maint mode/
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maint\.html$
RewriteRule ^(.*)$ http://website.com/maint.html [R=307,L]

1 个答案:

答案 0 :(得分:1)

脚本可以在启动时创建文件,您可以在htaccess和redirect中检查文件是否存在。当脚本完成时 - 它将删除该文件。

RewriteCond some_unique_name -f
RewriteCond %{REQUEST_URI} !^/maint\.html$
RewriteRule .* http://website.com/maint.html [R=307,L]

此处不需要括号。