PHP错误页面信息,自定义apache错误提示页面信息

假设你试着访问一个不存在或Apacha无法找到的页面时会反馈回404错误而且显示一个相当单调的提示错误的页面(通常还显示出网络管理员的电子邮件帐号)。

Apache所显示的的这些信息被储存在配置文件httpd.conf中。可以创建你自己的错误提示信息页面。

创建的的错误文件可以是一般的HTML,PHP或任何其他能被Apache所支持的网页文档格式。比如为404错误创建你的站点的提示页面,语法:

ErrorDocument 404 /404. php

你可以整体地使用它或在VirtualHost节单独设定。

当然,你必须提供这个文件; 在上述例子中,设定的是404.php,位于http://www.rootop.org/404.php。这一个文件应该包含错误信息和任何你想要说明的内容。

其他的错误信息也可以这么做。此外,你可以不创建单独页面就能显示你的个性化提示信息。举个例子:

ErrorDocument 500 “服务器出问题啦。请送花。”

Customize Apache’s default error pages

When Apache encounters an error, it displays a designated error message that’s prebuilt into the server. For example, let’s say that you try to load a page that Apache can’t find or that doesn’t exist. Apache returns a 404 (page not found) error and provides a rather drab Web page that indicates the error (and often the e-mail address of the Webmaster).

Apache draws this information from the data stored in the httpd.conf configuration file. However, you can spice things up by creating your own error documents.

Your error documents can be regular HTML, PHP, or any other Web document that the server supports. For instance, to create a new error message for a 404 error that better fits your site, use something like the following:

ErrorDocument 404 /404.php

You can use this globally or inside a VirtualHost stanza to affect one particular domain.

Of course, you must supply the file; in this example, it’s 404.php, located at http://www.yoursite.com/404.php. This file should contain the error message and anything else you want to specify.

You can also do this for any other error message type. In addition, you can present custom error messages without creating a whole page. Here’s an example:

ErrorDocument 500 “The server has encountered a problem. Please send flowers.”

专注于 服务器运维与web架构

E-mail:venus#rootop.org

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值