apache定制错误页面
编辑配置文件,错误页面定制支持三种形式:
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定制错误页面的更多相关文章
- springboot 定制错误页面
项目中经常遇到的异常情况 400-Bad Request 401-Unauthorized If the request already included Authorization credenti ...
- 【Laravel5】 定制错误页面
laravel5 所有异常错误都由类 App\Exceptions\Handler 处理,该类包含两个方法: report 和 render . 这里我们只看 render ...
- Spring boot错误处理以及定制错误页面
如果是浏览器访问,返回错误页面 注意浏览器发送请求的请求头: 注意区别其他客户端哦比如 postman 如果是其他客户端,返回一个Json数据 原理可以参照ErrorMvcAutoConfigura ...
- SpringBoot定制错误页面
(1)有模板引擎的情况下,例如404错误,将会在thymeleaf的templates的error下寻找404.html,如果找不到再寻找4xx.html *所有4开头的错误状态码如果找不到特定的ht ...
- thinkphp 定制错误页面
在前台配置文件里加上: 'TMPL_EXCEPTION_FILE' => '.Public/tpl/error.html',// 异常cuowu页面的模板文件 然后在Public下新建一个tpl ...
- nginx+apache 404错误页面
公司新系统 随风做的 给客户演示出错不想让客户看到 自动返回上一页面. 刚开始按照网上说的 在nginx 处理: # 定义错误提示页面 error_page 500 502 503 504 / ...
- ASP.NET Core应用的错误处理[1]:三种呈现错误页面的方式
由于ASP.NET Core应用是一个同时处理多个请求的服务器应用,所以在处理某个请求过程中抛出的异常并不会导致整个应用的终止.出于安全方面的考量,为了避免敏感信息的外泄,客户端在默认的情况下并不会得 ...
- Springboot学习05-自定义错误页面完整分析
Springboot学习06-自定义错误页面完整分析 前言 接着上一篇博客,继续分析Springboot错误页面问题 正文 1-自定义浏览器错误页面(只要将自己的错误页面放在指定的路径下即可) 1-1 ...
- SpringBoot定制错误的Json数据
(1)自定义异常处理&返回定制Json数据 @ControllerAdvice public class MyExceptionHandler { @ResponseBody @Excepti ...
随机推荐
- 特殊权限 - SUID GUID STICKYBIT
◆ SUID ( Set User ID ) Linux里,用户的ID被称作UID.在实际生产中,可能需要临时借用别的用户执行程序,因此需要能够临时变更自己UID的机能叫做SUID.借助SUID权限, ...
- java实现网络请求超时自动熔断
原文:https://www.jianshu.com/p/326465500d1c?utm_campaign 使用场景 之前在实现熔断降级组件时,需要实现一个接口的超时中断,意思是,业务在使用熔断降级 ...
- 【转】Golang汇编命令解读
原文: https://www.cnblogs.com/yjf512/p/6132868.html ------------------------------------------------- ...
- 解决CentOS虚拟机开机黑屏卡死问题
默认配置 导致的错误 1.直接就是黑屏,连杠杠都没有 2.centos系统关不掉 3.关闭vmware提示:虚拟机XXX繁忙 解决方式 一(我的失败,依旧不行)1.强制关闭vmware,重启计算机(不 ...
- Python+request 分模块存放接口,多接口共用参数URL、headers的抽离,添加日志打印等《三》
主要介绍内容如下: 1.分模块存放接口 2.多接口共用参数URL.headers的抽离为配置文件 3.添加日志打印 4.一个py文件运行所有所测的接口 如上介绍内容的作用: 1.分模块存放接口:方便多 ...
- Appium自动化测试教程-自学网-app基础知识
Instrumentation的缺点是不支持跨应用,比如我想要先调起通讯录,在操作其他的app,则不支持. 第一步,应该确定系统哪些模块适合自动化.哪些不适合做自动化,明确做自动化给我们带来的好处是什 ...
- CAZAC序列
定义: CAZAC(Const Amplitude Zero Auto-Corelation),即为恒包络零自相关序列. 性质: 1,恒包络特性:任意长度的CAZAC序列幅值恒定. 2,理想的周期自相 ...
- SIGAI深度学习第二集 人工神经网络1
讲授神经网络的思想起源.神经元原理.神经网络的结构和本质.正向传播算法.链式求导及反向传播算法.神经网络怎么用于实际问题等 课程大纲: 神经网络的思想起源 神经元的原理 神经网络结构 正向传播算法 怎 ...
- P4136 谁能赢呢? 脑子
思路:脑子(教练说是博弈论?) 提交:1次 题解: 结论:若\(n\)为奇数后手胜,若\(n\)为偶数先手胜. 大致证明: 我们发现,若我们把棋盘黑白染色并设左上角为黑色,那么显然有:若\(n\)为奇 ...
- 003_STM32程序移植之_W25Q64
1. 测试环境:STM32C8T6 2. 测试模块:W25Q64FLASH模块 3. 测试接口: 1. W25Q64FLASH模块接口: VCC3.3--------------------VCC3. ...