Add the 404 error page and access security to the ThinkPHP framework

Source: Internet
Author: User

All website projects need to add a 404 page, which is not only friendly, but also has some benefits for website optimization. The method of adding a 404 page to a website built using the ThinkPHP framework is still very simple, empty classes and empty methods are used.


Step 1:

Create EmptyAction. class. PHP In the Lib/Action folder

<?phpclass EmptyAction extends Action {function _empty(){header("HTTP/1.0 404 Not Found");$this->display('empty:index');}// 404function index() {header("HTTP/1.0 404 Not Found");$this->display('empty:index');}}

Step 2:

Modify all Action files in the Lib/Action folder and add the following code to all controller files:

function _empty(){header("HTTP/1.0 404 Not Found");$this->display('empty:index');}

Step 3,

Create page index.html under the Tpl/emptyfolder


If someone guesses the ThinkPHP framework you are using, they may find some Vulnerabilities Based on the ThinkPHP access method (it seems that some new PHP users like this)

To solve this problem, you can create a public class, including an empty class, which inherits this public class for determination.


Friends who like to discuss can join a group of 252799167

This article is from the "Thunder" blog, please be sure to keep this source http://a3147972.blog.51cto.com/2366547/1219682

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.