Thinkphp framework 404 page settings, thinkphp404_PHP tutorial

Source: Internet
Author: User
Thinkphp framework 404 page settings, thinkphp404. In the thinkphp framework, the 404 page is set. the thinkphp408244 page is an error message optimized when the system cannot find the requested operation method and the requested controller name. Step 1: Set the thinkphp 404 page under the thinkphp framework, thinkphp404

The 404 page is an error message optimized when the system cannot find the requested operation method or the requested controller name.

Step 1: Create an EmptyController. class. php instance in the Home/comtroler of the thinkphp framework. the code is as follows:

 Namespace Home \ Controller;
Use Think \ Controller;
Class EmptyController extends Controller {

// Empty operation_empty () method
Function _ empty (){
Header ("HTTP/1.0 404 Not Found ");
$ This-> displayed ("Public: 404 ");
}

Function index (){
Header ("HTTP/1.0 404 Not Found ");
$ This-> dislay ("Public: 404 ");
}
}
?>

Note: the header ("HTTP/1.0 404 Not Found") indicates that this status code is Not 404.

Step 2: create a public class PublicController. class. php in the Home/Comtroller of the thinkphp framework. the code is as follows:

 

Note: in the header ("Location:/bbs/thinkphp/404.html"),/bbs/thinkphp/404.html is the address of your 404th webpage. it must correspond to the Location of your 404.html page.

Step 3: let all other controllers inherit the PublicController. class. php in step 2, for example:

 

Note: comment out use Think \ Controller;

(Complete)

The lifecycle 404 page is an error message optimized when the system cannot find the requested operation method or the requested controller name. Step 1...

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.