最新消息:

有趣的404错误页面处理

产品 admin 2042浏览 0评论

The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but either the server could not find what was requested, or it was configured not to fulfill the request and not reveal the reason why. 404 errors should not be confused with “server not found” or similar errors, in which a connection to the destination server cannot be made at all.

摘自wikipedia HTTP 404

处理好诸如404错误这样的细节,对提高用户体验是极为关键的,一些关于404错误处理有趣的资源,

  • 404lab.com :专门搜集网络上面有趣的自定义404页面的网站

http://www.404lab.com/404/

  • smashingmagazine.com 关于404错误的几篇文档

http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/?

http://www.smashingmagazine.com/2007/07/25/wanted-your-404-error-pages/

  • 404错误的处理方式及对SEO的影响

http://www.bloghuman.com/post/227.htm

  • apache配置方式

如果打开了mod_rewrite,则在.htaccess中添加ErrorDocument指令

否则可以在httpd.conf中使用ErrorDocument指令

# ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
# ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
# ErrorDocument 403 /error.php
# ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
# ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
# ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
# ErrorDocument 410 /error/HTTP_GONE.html.var
# ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
# ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
# ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
# ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
# ErrorDocument 415 /error/HTTP_SERVICE_UNAVAILABLE.html.var
# ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
# ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
# ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
# ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
# ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

  • tomcat配置

在web.xml配置全局的错误码处理页面

<web-app>
<error-page>
<error-code>404</error-code>
<location>/NotFound.jsp</location>
</error-page>
</web-app>

或根据异常处理页面

<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/servletex.jsp</location>
</error-page>

Technorati 标签: ,

http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/?

转载请注明:出家如初,成佛有余 » 有趣的404错误页面处理

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址