编辑配置文件,错误页面定制支持三种形式:

1. 普通文本

2. 本地跳转

3. 外部跳转

[root@ken-node2 ~]# vim /etc/httpd/conf/httpd.conf
...
327 #
328 # Customizable error responses come in three flavors:
329 # 1) plain text 2) local redirects 3) external redirects
330 #
331 # Some examples:
332 #ErrorDocument 500 "The server made a boo boo."
333 #ErrorDocument 404 /missing.html
334 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 #ErrorDocument 402 http://www.example.com/subscription_info.html
...

普通文本

第一步:取消332行处的注释,如果404错误就会输出后面的一句话至页面

327 #
328 # Customizable error responses come in three flavors:
329 # 1) plain text 2) local redirects 3) external redirects
330 #
331 # Some examples:
332 ErrorDocument 404 "The server made a boo boo."
333 #ErrorDocument 404 /missing.html
334 #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
335 #ErrorDocument 402 http://www.example.com/subscription_info.html

第二步:修改完之后重启apache

[root@ken-node2 ~]# systemctl restart httpd

第三步:浏览器访问一个不存在的内容

本地跳转

第一步:编辑httpd配置文件

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 404 "The server made a boo boo."
ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html

第二步:编写错误页面

[root@ken-node2 html]# echo "this is missing page" > missing.html
[root@ken-node2 html]# ls
missing.html

第三步:重启httpd

[root@ken-node2 html]# systemctl restart httpd

第四步:浏览器测试

外部跳转

第一步: 编辑httpd配置文件

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 404 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
ErrorDocument 404 https://www.cnblogs.com/daisyyang/ #取消该行注释,后面跟上我的外部博客网址
#

第二步:重启httpd

[root@ken-node2 html]# systemctl restart httpd

第三步:浏览器访问

这个时候输入错误页面会直接跳转到我的博客

apache定制错误页面的更多相关文章

  1. springboot 定制错误页面

    项目中经常遇到的异常情况 400-Bad Request 401-Unauthorized If the request already included Authorization credenti ...

  2. 【Laravel5】 定制错误页面

    laravel5   所有异常错误都由类   App\Exceptions\Handler    处理,该类包含两个方法:   report   和   render . 这里我们只看 render  ...

  3. Spring boot错误处理以及定制错误页面

    如果是浏览器访问,返回错误页面 注意浏览器发送请求的请求头:  注意区别其他客户端哦比如 postman 如果是其他客户端,返回一个Json数据 原理可以参照ErrorMvcAutoConfigura ...

  4. SpringBoot定制错误页面

    (1)有模板引擎的情况下,例如404错误,将会在thymeleaf的templates的error下寻找404.html,如果找不到再寻找4xx.html *所有4开头的错误状态码如果找不到特定的ht ...

  5. thinkphp 定制错误页面

    在前台配置文件里加上: 'TMPL_EXCEPTION_FILE' => '.Public/tpl/error.html',// 异常cuowu页面的模板文件 然后在Public下新建一个tpl ...

  6. nginx+apache 404错误页面

    公司新系统  随风做的  给客户演示出错不想让客户看到   自动返回上一页面. 刚开始按照网上说的 在nginx 处理: # 定义错误提示页面 error_page 500 502 503 504 / ...

  7. ASP.NET Core应用的错误处理[1]:三种呈现错误页面的方式

    由于ASP.NET Core应用是一个同时处理多个请求的服务器应用,所以在处理某个请求过程中抛出的异常并不会导致整个应用的终止.出于安全方面的考量,为了避免敏感信息的外泄,客户端在默认的情况下并不会得 ...

  8. Springboot学习05-自定义错误页面完整分析

    Springboot学习06-自定义错误页面完整分析 前言 接着上一篇博客,继续分析Springboot错误页面问题 正文 1-自定义浏览器错误页面(只要将自己的错误页面放在指定的路径下即可) 1-1 ...

  9. SpringBoot定制错误的Json数据

    (1)自定义异常处理&返回定制Json数据 @ControllerAdvice public class MyExceptionHandler { @ResponseBody @Excepti ...

随机推荐

  1. 09_Azkaban案例实践2_Command多job工作流flow

    1.Command类型多job工作流flow 1.创建有依赖关系的多个job描述:第一个job:foo.job # foo.job type=command command=echo foo 2.第二 ...

  2. 在 Queue 中 poll()和 remove()有什么区别?(未完成)

    在 Queue 中 poll()和 remove()有什么区别?(未完成)

  3. pandas库介绍之DataFrame基本操作

    怎样删除list中空字符? 最简单的方法:new_list = [ x for x in li if x != '' ] 今天是5.1号. 这一部分主要学习pandas中基于前面两种数据结构的基本操作 ...

  4. 转 java 中int String类型转换

    转自licoolxue https://blog.csdn.net/licoolxue/article/details/1533364 int -> String int i=12345;Str ...

  5. [Google Guava] 6-字符串处理:分割,连接,填充

    原文链接 译文链接 译者:沈义扬,校对:丁一 连接器[Joiner] 用分隔符把字符串序列连接起来也可能会遇上不必要的麻烦.如果字符串序列中含有null,那连接操作会更难.Fluent风格的Joine ...

  6. vue文件夹上传插件选哪个好?

    文件夹数据库处理逻辑 public class DbFolder { JSONObject root; public DbFolder() { this.root = new JSONObject() ...

  7. 022_STM32中断优先级分组解析

    (0)STM32有十六个优先级 (一)STM32分组为:组0-4 (二)分组配置在寄存器SCB->AIRCR中: (三)解析第二点 1. 组0就是4位都用来设置成响应优先级,2^4=16位都是响 ...

  8. 基于Web的文件上传管理系统

    一般10M以下的文件上传通过设置Web.Config,再用VS自带的FileUpload控件就可以了,但是如果要上传100M甚至1G的文件就不能这样上传了.我这里分享一下我自己开发的一套大文件上传控件 ...

  9. ERROR 1010 (HY000): Error dropping database (can't rmdir './zabbix/', errno: 17)

    在删除数据库的时候报标题所示错误 mysql> drop database zabbix; ERROR 1010 (HY000): Error dropping database (can't ...

  10. 字典-Python基础前传(9)

    (一)Python中为什么要有字典 jacky说科学存在的逻辑只有两个: 1.解释问题 2.解决问题 我们明白了科学的逻辑,我们理解任何的知识和技能,都是很简单的 之前jacky跟大家说list因为太 ...