Home > Backend Development > PHP Tutorial > ThinkPHP method to access non-existent modules and jump to 404 page_PHP tutorial

ThinkPHP method to access non-existent modules and jump to 404 page_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:24:27
Original
871 people have browsed it

First create a new file EmptyAction.class.php in ACTION with the following code:

<&#63;php 
 class EmptyAction extends Action{ 
 function _empty(){ 
  header("HTTP/1.0 404 Not Found");//使HTTP返回404状态码 
  $this->display("Public:404"); 
 } 
 } 
 &#63;>

Copy after login

When using the apache server, you need to add ErrorDocument 404 /404.html to the website configuration in apache.

When using an iis server, you need to set a 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 settings of the application root directory, open the "web.config" file for editing, and add the following content to it:

<configuration>
 <system.web>
 <customErrors mode=”On” defaultRedirect=”error.asp”>
 <error statusCode=”404″ redirect=”notfound.asp” />
 </customErrors>
 </system.web>
 </configuration>
Copy after login

Note: In the above example, "error.asp" is the system's default 404 page, and "notfound.asp" is a customized 404 page. Please modify the corresponding file name when using it.
Then, add:

to the customized 404 page "notfound.asp"
<%
 Response.Status = “404 Not Found”
 %>
 

Copy after login

php 404 page:

 if(//如果没有任何结果)
   {
   //以前是仅仅显示“该帖子已经不存在”的提示,现在是:
   require('/404.php');
   @header('HTTP/1.1 404 Not Found'');
   @header('Status: 404 Not Found');
   exit;
   }
 
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825436.htmlTechArticleFirst create a new file EmptyAction.class.php in ACTION with the following code: php class EmptyAction extends Action{ function { function _empty(){ header("HTTP/1.0 404 Not Found"); // Make HTTP return...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template