Home > Backend Development > PHP Tutorial > ThinkPHP accesses non-existent modules and jumps to the 404 page_PHP tutorial

ThinkPHP accesses non-existent modules and jumps to the 404 page_PHP tutorial

WBOY
Release: 2016-07-20 11:11:19
Original
774 people have browsed it

Let’s introduce how ThinkPHP accesses non-existent modules and jumps to the 404 page. Friends in need can refer to it.

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

Open the apache httpd.conf configuration file or create a new .htaccess configuration file
The code is as follows
 代码如下 复制代码

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

Copy code

class EmptyAction extends Action{

function _empty(){
header("HTTP/1.0 404 Not Found"); // Make HTTP return 404 status code

$this->display("Public:404");

}

}

? >


 代码如下 复制代码







Set in apache


and add ErrorDocument 404 /404.html to your website configuration.

 代码如下 复制代码

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

Set in iis

Set 404 error page under IIS/ASP.net
 代码如下 复制代码

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


First, modify the settings of the application root directory, open the "web.config" file for editing, and add the following content to it:
The code is as follows

Copy code
Note: "error.asp" in the above example is the system's default 404 page , "notfound.asp" is a customized 404 page, please modify the corresponding file name when using it. Then, add in the customized 404 page "notfound.asp":
The code is as follows
Copy code
<%<🎜>Response.Status = “404 Not Found”<🎜>%> php 404
The code is as follows Copy code
if (if there are no results) { //Previously it only displayed "This post no longer exists" "The prompt is now: require('/404.php'); @header('HTTP/1.1 404 Not Found'); @header('Status: 404 Not Found') ; exit; } http://www.bkjia.com/PHPjc/444652.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444652.htmlTechArticle Let’s introduce how ThinkPHP can access non-existent modules and jump to the 404 page. Friends in need can refer to it. Create a new file EmptyAction.class.php in ACTION. The code in the file...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template