用戶在導航欄中輸入錯的的地址,頁面會出現錯誤信息。不想顯示錯誤信息,用戶在導航欄輸錯的時候,直接跳轉404.html頁面,如下步驟:
在Common->Conf->config.php中添加
'TMPL_EXCEPTION_FILE' => './404.html',// 異常頁面的模板文件 'ERROR_PAGE' => './404.html', // 錯誤定向頁面
即可,然后在根目錄添加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>
然后在導航欄隨意輸入地址時,顯示頁面為: