用户在导航栏中输入错的的地址,页面会出现错误信息。不想显示错误信息,用户在导航栏输错的时候,直接跳转404.html页面,如下步骤:

thinkphp 取消错误信息,跳转404.html

在Common->Conf->config.php中添加

'TMPL_EXCEPTION_FILE'   =>  './404.html',// 异常页面的模板文件
'ERROR_PAGE'            =>  './404.html', // 错误定向页面

即可,然后在根目录添加404.html文件

thinkphp 取消错误信息,跳转404.html

404.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>404页面错误</title>
    <style>
        #wei{ margin: 130px auto 0px 0px;height: 100px; width: 100%;text-align: center; font-size: 24px;text-shadow: 1px 1px 0 #CCC, 2px 2px 0 #CCC, /* end of 2 level deep grey shadow */ 3px 3px 0 #444, 4px 4px 0 #444, 5px 5px 0 #444, 6px 6px 0 #444; /* end of 4 level deep dark shadow */  }
        #wei { cursor: pointer; }
        a{ display: block; height: 50px; width: 100%; text-align: center;}
    </style>
</head>
<body>
    <div id="wei"></div>
    <a href="/Robotsgroup/index">点击返回“首页”>></a>
    <script>
        var c=document.getElementById("wei");
        c.innerHTML="404,未找到"+window.location.pathname+"页面";
    </script>
</body>
</html>

然后在导航栏随意输入地址时,显示页面为:

thinkphp 取消错误信息,跳转404.html

 

相关文章:

  • 2023-04-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2021-10-23
  • 2021-10-22
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2022-01-10
  • 2022-01-02
  • 2021-08-29
  • 2021-05-23
相关资源
相似解决方案