在 config.php 文件里面加

'http_exception_template' => [
        // 定义404错误的重定向页面地址
        404 => APP_PATH.'404.html',
        // 还可以定义其它的HTTP status
        401 => APP_PATH.'401.html',

    ],

404页面 放在 application 目录下

404模板页面404.html

<img src="__INDEX__/img/404.png" width="818" height="595" style="display: block;margin: 0 auto;">
<div class="" style="font-size: 36px;margin: 0 auto;text-align: center;color: #323232;">
    您查找的页面不存在,还有
    <span id="dd" style="color:darkorange;font-weight: bold;">6</span>
    秒,页面将自动跳转首页...
</div>
<!--倒计时-->
<script type="text/javascript">
function run(){
    var s = document.getElementById("dd");
    if(s.innerHTML == 0){
        window.location.href='/';
        return false;
    }
    s.innerHTML = s.innerHTML * 1 - 1;
}
window.setInterval("run();", 1000);
</script>

另附图片:

TP5设置404

相关文章: