thinkphp under Frame 404 Page Setup thinkphp support php5.2 thinkphp file thinkphp tags.ph

Source: Internet
Author: User
Tags php framework
404 page is The system cannot find the requested action method and cannot find the requested controller nameThe optimization of an error behavior.

The first step: Build a EmptyController.class.php in the Home/comtroller in the thinkphp framework with the following code:

  
   namespace Home\controller;
Use Think\controller;
Class Emptycontroller extends controller{

Empty Operation _empty () method
function _empty () {
Header ("http/1.0 404 Not Found");
$this, display ("public:404");
}

function index () {
Header ("http/1.0 404 Not Found");
$this-Dislay ("public:404");
}
}
?>

Note: where header ("http/1.0 404 Not Found") is defined this status code is not 404.

Step Two: Build a common class PublicController.class.php in Home/comtroller in the thinkphp framework, withthe following code:

 
  Phpnamespace Home\controller;  Use Think\controller; class extends controller{    function  _empty () {        header("location:/bbs/thinkphp/ 404.html ");}    }? >

Note: the /bbs/thinkphp/404.html in the header ("location:/bbs/thinkphp/404.html") Is the address that you appear after 404 page jump, need to correspond with own 404.html page place bit.

Step three: Let all other controllers inherit the PublicController.class.php in the second step , such as:

 
  Phpnamespace Home\controller; // Use Think\controller; class extends Publiccontroller {    publicfunction  index () {            *        * * *         }}? >

Note: Use think\controller; Comment out

Complete

The above describes the thinkphp framework under the 404 page setup, including the content of the thinkphp,php framework, I hope that the PHP tutorial interested in a friend helpful.

  • 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.