thinkphp制作404跳转页的简单实现方法
网上有很多thinkphp的404页面制作方法,但大多太过繁琐不简便,很烦人,所以为大家分享了最便捷的404制作方法,如下。
在thinkphp的公共目录的config配置文件中增加配置项:
'TMPL_EXCEPTION_FILE'=>'Public/404.html',
在Public文件夹中创建404.html内容如下
<!DOCTYPEhtml> <html> <head> <metacharset=utf-8"/> <title>404哟</title> <styletype="text/css"> body{ background-color:#ECECEC; font-family:'OpenSans',sans-serif; font-size:14px; color:#3c3c3c; } .demo{width:600px;margin:0auto;} .demop:first-child{ text-align:center; font-family:cursive; font-size:150px; font-weight:bold; line-height:100px; letter-spacing:5px; color:#fff; } .demop:first-childspan{ cursor:pointer; text-shadow:0px0px2px#686868, 0px1px1px#ddd, 0px2px1px#d6d6d6, 0px3px1px#ccc, 0px4px1px#c5c5c5, 0px5px1px#c1c1c1, 0px6px1px#bbb, 0px7px1px#777, 0px8px3pxrgba(100,100,100,0.4), 0px9px5pxrgba(100,100,100,0.1), 0px10px7pxrgba(100,100,100,0.15), 0px11px9pxrgba(100,100,100,0.2), 0px12px11pxrgba(100,100,100,0.25), 0px13px15pxrgba(100,100,100,0.3); -webkit-transition:all.1slinear; transition:all.1slinear; } .demop:first-childspan:hover{ text-shadow:0px0px2px#686868, 0px1px1px#fff, 0px2px1px#fff, 0px3px1px#fff, 0px4px1px#fff, 0px5px1px#fff, 0px6px1px#fff, 0px7px1px#777, 0px8px3px#fff, 0px9px5px#fff, 0px10px7px#fff, 0px11px9px#fff, 0px12px11px#fff, 0px13px15px#fff; -webkit-transition:all.1slinear; transition:all.1slinear; } .demop:not(:first-child){ text-align:center; color:#666; font-family:cursive; font-size:20px; text-shadow:01px0#fff; letter-spacing:1px; line-height:2em; margin-top:-50px; } </style> <scripttype="text/javascript"> functioncountDown(secs,surl){ varjumpTo=document.getElementById('jumpTo'); jumpTo.innerHTML=secs; if(--secs>0){ setTimeout("countDown("+secs+",'"+surl+"')",1000); } else{ location.href=surl; } } </script> </head> <body> <divclass="demo"> <p><span>4</span><span>0</span><span>4</span></p> <p>该页面不存在(′?ω?`)<spanid="jumpTo">5</span>秒后跳转到首页</p> </div> <scripttype="text/javascript"> countDown(5,'/'); </script> </body> </html>
这样就完成了,至于状态码当然是404了,因为thinkphp默认不存在的页面返回404,大功告成!最后再向大家推荐一个源码社区名字叫原创源码库,不错的网站,或许能够帮到您!
以上就是小编为大家带来的thinkphp制作404跳转页的简单实现方法的全部内容了,希望对大家有所帮助,多多支持毛票票~