当一个站点需要维护时,发送什么正确的HTTP状态代码?

时间:2022-05-23 01:51:55

Is there a HTTP status code to tell Google (and others) to go away, index me again later?

是否有HTTP状态码告诉谷歌(和其他)离开,稍后再索引我?

Basically, one that semantically tells clients that the site is down for maintenance?

基本上,一个从语义上告诉客户站点已经关闭进行维护的站点?

The ones I have considered are

我考虑过的是

304 => Not modified
307 => Temporary redirect
410 => Gone
503 => Service Unavailable

I'm leaning towards the last one, but was just curious as to which one was proper choice.

我倾向于最后一个,但只是好奇哪一个是正确的选择。

4 个解决方案

#1


90  

HTTP 503 - Service Unavailable would be the most appropriate.

HTTP 503 -服务不可用是最合适的。

The Web server (running the Web site) is currently unable to handle the HTTP request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

由于服务器的临时过载或维护,Web服务器(运行Web站点)当前无法处理HTTP请求。这意味着,这是一种暂时的状况,经过一段时间的拖延后将得到缓解。

This post on the Google Webmaster Central Forum is also relevant:

谷歌站长中心论坛上的这篇文章也是相关的:

Yes - a 503 is the correct server response for "We're closed". If you substitute a normal HTML page saying "We're closed" and serve a 200 it's very likely to get indexed by Google.

是的——503是“我们已经关闭”的正确服务器响应。如果你替换一个普通的HTML页面,说“我们已经关闭了”并提供了200个页面,它很可能会被谷歌索引。

If you give the Googlebot a 503, it will just go away and come back later without indexing what you give it.

如果你给Googlebot一个503,它就会消失,然后返回,而不需要索引你给它的东西。


UPDATE:

更新:

As for the php implementation, you may be interested in checking out the following article:

关于php实现,您可能有兴趣查看以下文章:

Also notice the retry-after header, where you can specify after how many seconds another request should be re-attempted.

还要注意retry-after报头,在该报头中,您可以指定应该重新尝试另一个请求的时间。

#2


6  

From http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

从http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

503 (Service unavailable) The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

服务器当前不可用(因为服务器过载或停机维护)。一般来说,这是一个暂时的状态。

#3


3  

I'd consider the 503 to be most appropriate, since the 5xx-group is meant for server errors in general.

我认为503是最合适的,因为5xx-group一般用于服务器错误。

#4


3  

503 Service Unavailable

503服务不可用

#1


90  

HTTP 503 - Service Unavailable would be the most appropriate.

HTTP 503 -服务不可用是最合适的。

The Web server (running the Web site) is currently unable to handle the HTTP request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

由于服务器的临时过载或维护,Web服务器(运行Web站点)当前无法处理HTTP请求。这意味着,这是一种暂时的状况,经过一段时间的拖延后将得到缓解。

This post on the Google Webmaster Central Forum is also relevant:

谷歌站长中心论坛上的这篇文章也是相关的:

Yes - a 503 is the correct server response for "We're closed". If you substitute a normal HTML page saying "We're closed" and serve a 200 it's very likely to get indexed by Google.

是的——503是“我们已经关闭”的正确服务器响应。如果你替换一个普通的HTML页面,说“我们已经关闭了”并提供了200个页面,它很可能会被谷歌索引。

If you give the Googlebot a 503, it will just go away and come back later without indexing what you give it.

如果你给Googlebot一个503,它就会消失,然后返回,而不需要索引你给它的东西。


UPDATE:

更新:

As for the php implementation, you may be interested in checking out the following article:

关于php实现,您可能有兴趣查看以下文章:

Also notice the retry-after header, where you can specify after how many seconds another request should be re-attempted.

还要注意retry-after报头,在该报头中,您可以指定应该重新尝试另一个请求的时间。

#2


6  

From http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

从http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

503 (Service unavailable) The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

服务器当前不可用(因为服务器过载或停机维护)。一般来说,这是一个暂时的状态。

#3


3  

I'd consider the 503 to be most appropriate, since the 5xx-group is meant for server errors in general.

我认为503是最合适的,因为5xx-group一般用于服务器错误。

#4


3  

503 Service Unavailable

503服务不可用