您的位置:首页 > 运维架构 > Tomcat

Tomcat启动不了时Apache自动跳转指定页面

2010-02-04 16:27 375 查看
首先我们的系统是Apache+Tomcat搭建的
1. Tomcat启动不了或者当机时,访问任何网站页面都返回503错误页面。由于这个页面比较简陋,无法给用户提供必要的信息以获取更多线索,无疑这会造成用户的流失。
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造成影响。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: