有利于各大搜索引擎友好SEO优化的404错误页面

有利于各大搜索引擎SEO优化的404页面html

代码如下:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 核心SEO配置:禁止搜索引擎收录、禁止追踪链接 -->
    <meta name="robots" content="noindex, nofollow, noarchive">
    <!-- 百度、搜狗、360 专项SEO适配 -->
    <meta name="baidu-spider" content="noindex,nofollow">
    <meta name="sogou-spider" content="noindex,nofollow">
    <meta name="360-spider" content="noindex,nofollow">
    <!-- 页面关键词与描述(SEO兜底优化) -->
    <meta name="keywords" content="404页面,页面不存在,网站错误页面">
    <meta name="description" content="您访问的页面不存在或已删除,返回网站首页浏览更多优质内容。">
    <title>404-页面未找到 | 页面不存在</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft Yahei", PingFang SC, SimHei, sans-serif;
        }
        body {
            width: 100%;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background-color: #f8f9fa;
            color: #333;
        }
        .404-container {
            text-align: center;
            padding: 20px;
            max-width: 600px;
            width: 100%;
        }
        .404-code {
            font-size: 120px;
            font-weight: 700;
            color: #2d8cf0;
            line-height: 1.2;
            margin-bottom: 20px;
        }
        .404-title {
            font-size: 24px;
            color: #333;
            margin-bottom: 15px;
            font-weight: 500;
        }
        .404-desc {
            font-size: 16px;
            color: #666;
            line-height: 1.8;
            margin-bottom: 30px;
        }
        .404-btn {
            display: inline-block;
            padding: 12px 30px;
            background-color: #2d8cf0;
            color: #fff;
            text-decoration: none;
            border-radius: 6px;
            font-size: 16px;
            transition: all 0.3s ease;
        }
        .404-btn:hover {
            background-color: #1b76d8;
        }
        .404-tips {
            margin-top: 25px;
            font-size: 14px;
            color: #999;
        }
        /* 移动端自适应优化 */
        @media (max-width: 768px) {
            .404-code {
                font-size: 80px;
            }
            .404-title {
                font-size: 20px;
            }
            .404-desc {
                font-size: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="404-container">
        <div class="404-code">404</div>
        <h1 class="404-title">抱歉!您访问的页面不存在</h1>
        <p class="404-desc">可能是页面链接错误、内容已删除或暂时迁移,请勿担心,您可以返回首页继续浏览更多精彩内容。</p>
        <a href="/" class="404-btn">返回网站首页</a>
        <p class="404-tips">页面将在 <span id="time">5</span> 秒后自动跳转首页</p>
    </div>

    <script>
        // 5秒自动跳转首页 SEO优化(不使用301/302跳转,保留404状态)
        let timer = 5;
        const timeDom = document.getElementById('time');
        setInterval(() => {
            timer--;
            timeDom.innerText = timer;
            if (timer <= 0) {
                window.location.href = '/';
            }
        }, 1000);
    </script>
</body>
</html>

显示效果如下图: