核心代码:
复制代码 代码如下:
@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();
查看404是否设置成功可以利用firefox 的firebug插件来查看
查看方法
在已经安装firebug的情况下,用firefox浏览器打开要检查404状态码的页面,点击右下角小虫的图标,启动"网络"标签,依次打开"网络–所有/html–headers";如果一切正常,你就可以看到包括headers、响应在内的各项页面参数了。
404页面对网站影响
对seo的影响并不大。但是有,总比没有好。如果你拥有这个权限,你最好还是设置一下404页面。这个东西跟网站地图一样,不是所有的网站都得设置,但是有时候有设置的必要。
再考虑是不是要设置404页面时,应该多考虑用户体验,而不是seo。
看一下apache 404定义吧
apache里设置404错误页面为apache server设置 404错误页面的方法很简单,只需在.htaccess 文件中加入如下内容即可:
errordocument 404 /notfound.php

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.