search
HomePHP FrameworkThinkPHPHow to create a 404 jump page in Thinkphp

How to create a 404 jump page in Thinkphp

Mar 27, 2020 pm 01:32 PM
404thinkphp

This article introduces how to use ThinkPHP to implement a 404 page. I hope it will be helpful to friends who are learning thinkphp!

How to create a 404 jump page in Thinkphp

How to create a 404 redirect page in Thinkphp

There are many thinkphp 404 page creation methods on the Internet, but most of them are too cumbersome. It's simple, but it's annoying, so I'm sharing with you the most convenient way to make 404, as follows.
Add configuration items to the config configuration file in the public directory of thinkphp:

'TMPL_EXCEPTION_FILE' => 'Public/404.html',

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>

This is done, as for the status code Of course it's 404, because thinkphp returns 404 by default for pages that don't exist, and you're done!

(Recommended tutorial: thinkphp tutorial)

The above is the detailed content of How to create a 404 jump page in Thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.