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 ;}