apache定制错误页面

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

1. 普通文本node

2. 本地跳转apache

3. 外部跳转vim

复制代码
[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

 

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

 

本地跳转

 

第一步:编辑httpd配置文件spa

复制代码
#
# 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
复制代码

 

第二步:编写错误页面rest

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

 

第三步:重启httpdcode

[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

 

第三步:浏览器访问

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

相关文章
相关标签/搜索