ThinkPHP method for accessing a module that does not exist to jump to the 404 page _ php instance

Source: Internet
Author: User
This article mainly introduces ThinkPHP's method to access a module that does not exist to jump to the 404 page. For more information, see create a file EmptyAction. class. php in ACTION. The code is as follows:

<? Php class EmptyAction extends Action {function _ empty () {header ("HTTP/1.0 404 Not Found "); // make HTTP return 404 status code $ this-> display ("Public: 404") ;}}?>

To use the apache server, add ErrorDocument 404/404. html to the apache website configuration.

When using the iis server, you must set the 404 error page under iis/ASP.net in IIS.

Open the apache httpd. conf configuration file or create a new. htaccess configuration file.

First, modify the application root directory settings, open the "web. config" file, and add the following content to it:

  
   
    
     
    
   
 

Note: In the preceding example, "error. asp" is the default 404 page and "notfound. asp" is the custom 404 page. modify the file name when using it.
Then, add the following content to the custom 404 page "notfound. asp:

<% Response.Status = “404 Not Found” %> 

Php 404 page:

If (// if there are no results) {// previously, only the prompt "this post does not exist" was displayed. now it is: require ('/404. php '); @ header ('http/1.1 404 Not Found'); @ header ('status: 404 Not Found '); exit ;}

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.