2010-03-02 74 views

回答

5
Options +FollowSymlinks 
RewriteEngine on 
RewriteCond %{REQUEST_URI} !/holding_page.php$ 

RewriteRule $ /holding_page.php$l [R=307,L] 

使用307(感谢Piskvor!),而不是302 - 307 means

所请求的资源所在 暂时下一个不同的URI。 由于有时重定向可能会被修改为 ,客户端SHOULD 将继续使用Request-URI来处理将来的请求。

+3

+1,但在这种情况下,我会使用临时重定向:[R = 307,L] – Piskvor 2010-03-02 09:23:26

+0

@皮克沃尔 - 出色的建议,编辑于! – 2010-03-02 09:25:34

+0

这是给我一个内部服务器错误? – stef 2010-03-03 14:23:31

-3

这工作得更好......

Options +FollowSymlinks 
RewriteEngine on 
RewriteCond %{REQUEST_URI} !/holding_page.php$ 
RewriteRule $ /holding_page.php [R=307,L] 
1

当我碰到这个问题来了,这里是我使用的解决方案(在评论简要说明):

RewriteEngine On 
RewriteBase/

# do not redirect when using your IP if necessary 
# edit to match your IP 
RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1 

# do not redirect certain file types if necessary 
# edit to match the file types needed 
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css) 

# this holding page that will be shown while offline 
RewriteCond %{REQUEST_URI} !^/offline\.html$ 

# use 503 redirect code during the maintenance job 
RewriteRule ^(.*)$ /offline.html [R=503,L] 
ErrorDocument 503 /offline.html 

# bots should retry accessing your page after x seconds 
# edit to match your maintenance window 
Header always set Retry-After "3600" 

# disable caching 
Header Set Cache-Control "max-age=0, no-cache, no-store" 

除了附加条件和标题,主要想法是使用503状态代码当您正在执行维护工作。

503代码代表Service Unavailable,在维护过程中就是这种情况。使用此功能也会对搜索引擎优化很有帮助,因为漫游器不会为503网页编制索引,而且它们会在指定的Retry-After后面再回来查找实际内容。

这里了解更多详细信息:

相关问题