ThinkPHP accesses a module that does not exist and jumps to the 404 page.

Source: Internet
Author: User
ThinkPHP accesses a module that does not exist and jumps to the 404 page.

Create a file EmptyAction. class. php in ACTION. The code in the file is as follows:

  1. Class EmptyAction extends Action {
  2. Function _ empty (){
  3. Header ("HTTP/1.0 404 Not Found"); // returns the 404 status code for HTTP
  4. $ This-> displayed ("Public: 404 ");
  5. }
  6. }
  7. ?>
Copy code

Set in apache

Add ErrorDocument 404/404. html to your website configuration.

Set in iis

Set error 404 page under IIS/ASP.net

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:

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
Copy code

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:

  1. <%
  2. Response. Status = "404 Not Found"
  3. %>
  4.  
Copy code

Python 404

  1. If (if there are no results)
  2. {
  3. // In the past, only the prompt "this post does not exist" was displayed. now it is:
  4. Request ('/404. php ');
  5. @ Header ('http/1.1 404 Not Found ');
  6. @ Header ('status: 404 Not Found ');
  7. Exit;
  8. }

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.