HDwiki 自定义404 方法

2012-02-10 浏览:1445
HDwiki 自定义404 方法
评论:(0)复制地址

hdwiki开启伪静态后无法自定义404页面,即便服务器设置了,也不行,只能自己修改程序,自定义404页面。

修改方法:

/model/hdwiki.class.php 最后一行

function notfound($error){
                @header('HTTP/1.0 404 Not Found');
                exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1><p> $error </p></body></html>");
        }

修改为:

function notfound($error){
                header('Location:404.html');
      }


2020年1月20新增:以上方法会导致返回302状态,现在优化如下:


function notfound($error){

@header('HTTP/1.0 404 Not Found');

//exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"><html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1><p> $error </p></body></html>");

exit("<!DOCTYPE HTML><html><head><meta charset=\"UTF-8\" /><title>公益404</title><style type=\"text/css\">.foshang_logo{width100%;text-align:center}.mod_404 .wrapper{top:0!important;margin-top: 220px!important;}@media screen and (max-width: 720px){.foshang_logo{margin-top:20px}.foshang_logo img{width:150px}.mod_404 .wrapper{margin-top: 20px!important;}.mod_404 .title{background: url(https://qzone.qq.com/gy/404/style/image/txt_title.png) center center no-repeat!important;background-size: calc(100% - 20px) auto!important;height: 70px!important;}.mod_404 .title .title_inner { display: none!important; line-height: 1.2;}}</style></head><body><script type=\"text/javascript\" src=\"http://qzone.qq.com/gy/404/data.js\"></script><script type=\"text/javascript\" src=\"http://www.foshang.net/statics/js/404.js\"></script></body></html>");

}

这个方法是将404的内容直接展示!

评论:(0)复制地址
发布:苗景云 | 分类:IT技术&设计 | Tags:hdwiki 404

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。