404頁面就是一個告訴搜索引擎這個頁面不存在了,同時也提示用戶可以選擇其它的操作了,下面我來給沒有apache操作權限朋友介紹php中自定義404頁面的操作方法.
實例代碼如下:
- @header("http/1.1 404 not found");
- @header("status: 404 not found");
- echo 'echo 404';
- exit();
加載一個404錯誤頁面
實例代碼如下:
- @header("http/1.1 404 not found");
- @header("status: 404 not found");
- include("../../404.htm");
- exit();
也可以在站點中加入.htaccess,實例代碼如下:
- errordocument 404 /404.html
如果有apahce配置權限,我們可以修改 httpd.conf,找到:
實例代碼如下:
- #ErrorDocument 500 "The server made a boo boo."
- #ErrorDocument 404 /missing.html
- #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
- #ErrorDocument 402 xxxxxxx
修改為
實例代碼如下:
- ErrorDocument 404 /404.htm
新聞熱點
疑難解答