eyoucms自定义404页面

404个性化页面自定义是我们很多时候都会有的需求,修改的办法也很简单,修改后记得自己拿小本本记着,下次系统更新如果被覆盖了,还可以再改回来,自定义404页面,PC、手机都可自己判断地址。

方法:
Core/library/think/exception/handle.php 找到方法 renderHttpException
对原来的if判断进行一下改良,结果如下:
地址自动切换到pc/mobile目录下,所以两个目录都要有自己的404.html

if('404' == $status){
    $mytemplate = \think\Config::get('template.view_path');
    $mytemplate = ROOT_PATH.$mytemplate.'404.htm';
    return Response::create($mytemplate, 'view', $status)->assign(['e' => $e]);
} elseif (!empty($template[$status])) {
    return Response::create($template[$status], 'view', $status)->assign(['e' => $e]);
} else {
        return $this->convertExceptionToResponse($e);
}

好了,这是二开办法,需要做成插件可以留言讨论

猜你喜欢

转载自blog.51cto.com/14747960/2486651