因此,在更新某些内容时,我使用以下内容强制我的网站进入维护模式:
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^23\.1\.12\.167
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
这一点运作良好,但是现在我处于维护模式的情况下,我希望将某些目录排除在发送到maintenance.html之外,而是让它们显示正常内容。
所以它会是这样的:
root/
.htaccess
maintenance.html
index.html
everything.else.html
/do_not_display_me
/display_me_always
不确定这是否可以从根级别.htaccess或如果我将不得不使用sub-dir .htaccess文件,任何帮助表示赞赏。
答案 0 :(得分:2)
这应该可以胜任。它告诉Apache不要重写那些文件夹(这使得维护规则被省略,因为重写链永远不会到达它们)。
# activate rewrite engine
RewriteEngine on
# always allow these folders
RewriteCond %{REQUEST_URI} ^/display_me_always [OR]
RewriteCond %{REQUEST_URI} ^/another_folder [OR]
RewriteCond %{REQUEST_URI} ^/even_more_folders
RewriteRule .+ - [L]
# maintenance rules
RewriteCond %{REMOTE_ADDR} !^23\.1\.12\.167
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
NC,
与[OR]
匹配。/
。