zoukankan      html  css  js  c++  java
  • 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

    第三步:浏览器访问

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

  • 相关阅读:
    java线程与并发(二)
    互联网金融时代的机遇和挑战
    SQL Server获取下一个编码字符串的实现方案分割和进位
    SQL Server获取下一个编码字符实现继续重构与增强
    SQL Server获取下一个编码字符实现
    SQL Server数字辅助表的实现
    SQL Server中中数据行批量插入脚本的存储实现
    SQL Server中的RAND函数的介绍和区间随机数值函数的实现
    SQL Server中字符串转化为GUID的标量函数实现
    SQL Server 中获取字符串拼音的标量函数实现
  • 原文地址:https://www.cnblogs.com/daisyyang/p/11112275.html
Copyright © 2011-2022 走看看