1. 默认的由Apache自动处理的404

    修改Aache的配置文件 httpd.conf 中的

    ErrorDocument 404 /404.html

    或者使用 .htaccess文件,同时有要把 httpd.conf中的deny都改成allow

    文件里也是写上面那句 ErrorDocument 404 /404.html 就可以了

2. 人工强制返回404状态码

1 function error_to_back_home(){
2     /*@是抑制显示错误信息,有错也不显示*/
3     @header("http/1.1 404 not found"); 
4     @header("status: 404 not found"); 
5     @header("location: /404.html"); //跳转到404页面
6     exit();
7 }
View Code

相关文章: