Home > php教程 > PHP开发 > body text

A simple way to create a 404 jump page using thinkphp

高洛峰
Release: 2016-12-21 16:30:58
Original
1780 people have browsed it

There are many thinkphp 404 page creation methods on the Internet, but most of them are too cumbersome, inconvenient, and annoying, so I will share with you the most convenient 404 creation method, as follows.
Add configuration items to the config configuration file in thinkphp's public directory:

'TMPL_EXCEPTION_FILE' => 'Public/404.html',
Copy after login

Create 404.html in the Public folder with the following content

<!DOCTYPE html >
<html>
<head>
<meta charset=utf-8" />
<title>404哟</title>
<style type="text/css">
body {
 background-color: #ECECEC;
 font-family: &#39;Open Sans&#39;, sans-serif;
 font-size: 14px;
 color: #3c3c3c;
}
.demo{width:600px;margin:0 auto;}
.demo p:first-child {
 text-align: center;
 font-family: cursive;
 font-size: 150px;
 font-weight: bold;
 line-height: 100px;
 letter-spacing: 5px;
 color: #fff;
}
 
.demo p:first-child span {
 cursor: pointer;
 text-shadow: 0px 0px 2px #686868,
  0px 1px 1px #ddd,
  0px 2px 1px #d6d6d6,
  0px 3px 1px #ccc,
  0px 4px 1px #c5c5c5,
  0px 5px 1px #c1c1c1,
  0px 6px 1px #bbb,
  0px 7px 1px #777,
  0px 8px 3px rgba(100, 100, 100, 0.4),
  0px 9px 5px rgba(100, 100, 100, 0.1),
  0px 10px 7px rgba(100, 100, 100, 0.15),
  0px 11px 9px rgba(100, 100, 100, 0.2),
  0px 12px 11px rgba(100, 100, 100, 0.25),
  0px 13px 15px rgba(100, 100, 100, 0.3);
 -webkit-transition: all .1s linear;
 transition: all .1s linear;
}
 
.demo p:first-child span:hover {
 text-shadow: 0px 0px 2px #686868,
  0px 1px 1px #fff,
  0px 2px 1px #fff,
  0px 3px 1px #fff,
  0px 4px 1px #fff,
  0px 5px 1px #fff,
  0px 6px 1px #fff,
  0px 7px 1px #777,
  0px 8px 3px #fff,
  0px 9px 5px #fff,
  0px 10px 7px #fff,
  0px 11px 9px #fff,
  0px 12px 11px #fff,
  0px 13px 15px #fff;
 -webkit-transition: all .1s linear;
 transition: all .1s linear;
}
 
.demo p:not(:first-child) {
 text-align: center;
 color: #666;
 font-family: cursive;
 font-size: 20px;
 text-shadow: 0 1px 0 #fff;
 letter-spacing: 1px;
 line-height: 2em;
 margin-top: -50px;
}
 
</style>
<script type="text/javascript"> 
function countDown(secs,surl){ 
  var jumpTo = document.getElementById(&#39;jumpTo&#39;);
  jumpTo.innerHTML=secs;
  if(--secs>0){ 
    setTimeout("countDown("+secs+",&#39;"+surl+"&#39;)",1000); 
   } 
  else{  
    location.href=surl; 
  } 
} 
</script>
</head>
 
<body>
 
<div class="demo">
  <p><span>4</span><span>0</span><span>4</span></p>
  <p>该页面不存在(′?ω?`)<span id="jumpTo">5</span>秒后跳转到首页</p>
</div>
<script type="text/javascript">
  countDown(5,&#39;/&#39;);
</script>
</body>
</html>
Copy after login

That's it. As for the status code, of course it is 404, because thinkphp returns 404 by default for pages that do not exist. You're done! Finally, I would like to recommend a source code community called Original Source Code Library. It is a good website and may be able to help you!

The above is the entire content of the simple implementation method of creating a 404 jump page with thinkphp brought to you by the editor. I hope it will be helpful to everyone. Please support the PHP Chinese website~

More ideas for creating a 404 jump page with thinkphp For articles related to simple implementation methods, please pay attention to the PHP Chinese website!


Related labels:
404
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!