如何返回错误代码503
有时候为了进行网站的维护,需要较长时间的关闭网站,可以做一个网站正在维护的页面来显示。但是又担心搜索引擎的机器人会将这个页面进行索引,这时,可以让服务器返回一个503的状态代码,而不是200的状态代码,这样机器人就会知道回头再来试看看。
503(服务不可用)服务器目前无法使用(由于超载过停机维护)。通常,这只是暂时状态。
200(成功)服务器已成功处理了请求。通常,这表示服务器提供了请求的网页。
使用Apache服务器时,可以编辑一个shell命令为503.sh:
cat <<EOF Status: 503
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>503 - Service temporary unavailable</title>
</head>
<body>
<h1>503 - Service temporary unavailable</h1>
<p>Sorry, this website is currently down for maintainance please retry in a few minutes</p>
</body>
</html>
EOF
将下面的命令行加入到confiig中,重新启动服务器。
ScriptAlias / /path/to/your/503.sh/
[tags]503,googlebot[/tags]
Comments (One comment)
There are no comments for this post so far.
Post a comment