thinkphp access to non-existent modules jump to 404 page method _php Tutorial

Source: Internet
Author: User
Tags php class
First create a new file EmptyAction.class.php in action with the following code:

<?php  class Emptyaction extends action{  function _empty () {   header ("http/1.0 404 Not Found");// Make HTTP return 404 status Code   $this->display ("public:404");  }  }  ? >

In the case of Apache server, you will need to add errordocument 404/404.html to the site configuration in Apache.

In the case of an IIS server, you need to set the 404 error page under Iis/asp.net in IIS.

Open the Apache httpd.conf configuration file or create a new. Htaccess profile

First, modify the settings of the application root to open the "Web. config" file editor, adding the following:

 
   
  
    
   
     
    
      
   
     
  
    
 
  

Note: In the example above, "error.asp" is the default 404 page of the system, "notfound.asp" is a custom 404 page, please modify the corresponding file name when using.
Then, in the Custom 404 page "Notfound.asp", add:

PHP 404 Page:

if (//if there is no result)   {   //previously only shows "the Post no longer exists" prompt, now is:   require ('/404.php ');   @header (' http/1.1 404 Not Found ');   @header (' status:404 not Found ');   Exit   

http://www.bkjia.com/PHPjc/825436.html www.bkjia.com true http://www.bkjia.com/PHPjc/825436.html techarticle first create a new file EmptyAction.class.php in Action with the following code: PHP class Emptyaction extends action{function _empty () {Header (" http/1.0 404 Not Found ");//Make HTTP return ...

  • Related Article

    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.