2. 我们使用自定义503错误的方式以提供用户友好体验,避免用户流失。
我们要处理的逻辑就是:把503错误跳转到一个页面,我们取名叫:missing503.html
然后再这个页面中实现我们需要的功能。
首先定义跳转:在apache配置文件的虚拟站点定义中使用如下语句即可。
ErrorDocument 503 /help_static/missing503.html (建议使用相对路径,下面的定义表示missing503.html文件存放在DocumentRoot下的help_static目录中)
定义完成后的虚拟站点如下 (红色代表新加内容)
<VirtualHost *:443>
# General setup for the virtual host
DocumentRoot "/opt/app/mydomain_1.1_static"
ServerName www.mydomain.com
ServerAdmin postmaster@mydomain.com
ErrorLog "/var/log/httpd/error_log"
TransferLog "/var/log/httpd/access_log"
ErrorDocument 503 /help_static/missing503.html
......
</VirtualHost>
......
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
ErrorDocument 503 /help_static/missing503.html
3. 关于SEO
这里提供一个检查HTTP状态码网站
http://www.seoconsultants.com/tools/headers.asp#status-codes
通过这个网站的检测,自定义503错误页面,返回的是“503”错误代码,而不是“200”或“302”。因此理论上不会对SEO造成影响。