Rootop 服务器运维与web架构

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

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

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

创建的的错误文件可以是一般的HTML,PHP或任何其他能被Apache所支持的网页文档格式。比如为404错误创建你的站点的提示页面,语法:
ErrorDocument 404 /404. php
你可以整体地使用它或在VirtualHost节单独设定。

当然,你必须提供这个文件; 在上述例子中,设定的是404.php,位于https://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.”

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/1216.html

作者:Venus

服务器运维与性能优化

评论已关闭。