ThinkPHP404 page setting method

Source: Internet
Author: User
This article describes how to set ThinkPHP404 pages. For more information, see

This article describes how to set ThinkPHP 404 pages. For more information, see

How can I set the 404 page in the ThinkPHP framework for many websites? Next I will introduce one of the methods.

1. First, create the EmptyAction. class. php module under Lib/Action.
The content is as follows:

The Code is as follows:


<? Php
/*
* @ Author rocky
* @ Date 20141021
* @ Desc: Error of empty module 404
**/
Class EmptyAction extends CommonAction {
Function _ empty (){
Header ("HTTP/1.0 404 Not Found ");
$ This-> display ('Public: 404 ');
}
}
?>

2. After completing the above processing, we can only access the 404 page when accessing the empty module. Therefore, to access the 404 page for the empty method, we also need to go to CommonAction. class. add an empty Method for php as follows:

The Code is as follows:


// Process all the methods that do not exist and direct them to the 404 page
Public function _ empty (){
R ('empty'/_ empty ');
}

3rd, you can complete the work, but do not forget to put your 404.html page under Tpl/Public

In this case, OK. All right, close the team !~~~

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.