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

    第三步:浏览器访问

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

  • 相关阅读:
    【BZOJ2227】【ZJOI2011】看电影 [组合数][质因数分解]
    【BZOJ2648】SJY摆棋子 [KD-tree]
    【BZOJ3237】【AHOI2013】连通图 [CDQ分治]
    【BZOJ1901】Dynamic Rankings [整体二分]
    【BZOJ2527】【POI2011】Meteors [整体二分]
    【BZOJ3624】【APIO2008】免费道路 [生成树][贪心]
    【BZOJ2663】灵魂宝石 [二分]
    【BZOJ4653】【NOI2016】区间 [线段树]
    【BZOJ2049】【SDOI2008】洞穴勘测 [LCT]
    【BZOJ4008】【HNOI2015】亚瑟王 [期望DP]
  • 原文地址:https://www.cnblogs.com/daisyyang/p/11112275.html
Copyright © 2011-2022 走看看