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

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. 向量的一种特殊乘法 element wise multiplication

    向量的一种特殊乘法 element wise multiplication 物体反射颜色的计算采用这样的模型: vec3 reflectionColor = objColor * lightColor ...

  2. 华中校赛 14th

    https://www.nowcoder.com/acm/contest/106#question A 分类讨论 #include<bits/stdc++.h> using namespa ...

  3. HTTP通过Get请求传递参数时特殊字符被转码的处理方式

    有些符号在URL中是不能直接传递的,如果要在URL中传递这些特殊符号,那么就要使用他们的编码了. 编码的格式为:%加字符的ASCII码,即一个百分号%,后面跟对应字符的ASCII(16进制)码值.例如 ...

  4. Codeforces Round #539 (Div. 1) C. Sasha and a Patient Friend 动态开点线段树

    题解看这里 liouzhou_101的博客园 更简洁的代码看这里: #include <bits/stdc++.h> using namespace std; typedef long l ...

  5. docker的网络服务

    docker提供 网络服务,主要通过两种方式: 1.外部访问 2.容器互联 通过外部访问Docker容器,主要通过端口映射的方式. [root@docker ~]# docker run -t -P ...

  6. npm install、npm install --save与npm install --save-dev (转)

    仅供学习参考,侵权删 以npm安装msbuild为例: npm install msbuild: 会把msbuild包安装到node_modules目录中 不会修改package.json 之后运行n ...

  7. MySQL组提交(group commit)

    MySQL组提交(group commit) 前提: 以下讨论的前提 是设置MySQL的crash safe相关参数为双1: sync_binlog=1 innodb_flush_log_at_trx ...

  8. ueditor+粘贴word

    Chrome+IE默认支持粘贴剪切板中的图片,但是我要发布的文章存在word里面,图片多达数十张,我总不能一张一张复制吧?Chrome高版本提供了可以将单张图片转换在BASE64字符串的功能.但是无法 ...

  9. luoguP3366 【模板】最小生成树 x

    P3366 [模板]最小生成树 2.4K通过 6.3K提交 题目提供者HansBug 标签 云端↑ 生成树 难度 普及- 时空限制 1s / 128MB 题目描述 如题,给出一个无向图,求出最小生成树 ...

  10. Collection接口详解

    Collection 介绍 https://blog.csdn.net/jyg0723/article/details/80498840 Stream API介绍  https://www.jians ...