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