初然忆

用EO-Pages实现域名@记录跳转

原因

由于我的博客绑定的域名是www.imcry.vip。

有博主反馈,在直接访问imcry.vip时并不会自动跳转到www.imcry.vip。

域名在使用阿里云DNS解析时可以直接添加@记录的显性URL跳转。

不过博主在切换到华为云的DNS解析后因为不是企业认证导致无法添加此类型的记录。

解决

使用Edge-Pages部署一个跳转页面。

页面代码

使用DeepSeek简单搓了个秒跳转的页面。

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>初然忆 - 正在跳转…</title>
    <meta http-equiv="refresh" content="0; url=https://www.imcry.vip/" />
    <style>
        /* 简洁美观的跳转提示页样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background: #f8fafc;
            padding: 20px;
        }
        .card {
            max-width: 480px;
            width: 100%;
            background: #ffffff;
            border-radius: 20px;
            padding: 48px 40px;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
            text-align: center;
            transition: all 0.2s;
        }
        .icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 72px;
            height: 72px;
            border-radius: 50%;
            background: #eef2ff;
            color: #4f46e5;
            font-size: 32px;
            margin-bottom: 24px;
        }
        h1 {
            font-size: 22px;
            font-weight: 600;
            color: #0f172a;
            letter-spacing: -0.3px;
            margin-bottom: 10px;
        }
        p {
            font-size: 16px;
            color: #64748b;
            line-height: 1.6;
            margin-bottom: 28px;
        }
        .url-box {
            display: inline-block;
            background: #f1f5f9;
            padding: 8px 20px;
            border-radius: 40px;
            font-size: 15px;
            font-weight: 500;
            color: #0f172a;
            word-break: break-all;
            margin-bottom: 8px;
        }
        .spinner {
            display: inline-block;
            width: 22px;
            height: 22px;
            border: 3px solid #e2e8f0;
            border-top-color: #4f46e5;
            border-radius: 50%;
            animation: spin 0.7s linear infinite;
            margin-top: 8px;
        }
        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }
        .footer {
            margin-top: 24px;
            font-size: 13px;
            color: #94a3b8;
        }
        .footer a {
            color: #4f46e5;
            text-decoration: none;
        }
        .footer a:hover {
            text-decoration: underline;
        }

        /* 暗色适配 */
        @media (prefers-color-scheme: dark) {
            body {
                background: #0f172a;
            }
            .card {
                background: #1e293b;
                box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
            }
            h1 {
                color: #f1f5f9;
            }
            p {
                color: #94a3b8;
            }
            .url-box {
                background: #334155;
                color: #f1f5f9;
            }
            .spinner {
                border-color: #475569;
                border-top-color: #818cf8;
            }
            .icon {
                background: #1e293b;
                color: #818cf8;
            }
            .footer {
                color: #64748b;
            }
            .footer a {
                color: #818cf8;
            }
        }

        /* 小屏优化 */
        @media (max-width: 480px) {
            .card {
                padding: 32px 24px;
            }
            h1 {
                font-size: 19px;
            }
        }
    </style>
</head>
<body>

    <div class="card">
        <!-- 图标 -->
        <div class="icon">↗</div>

        <h1>正在跳转</h1>
        <p>
            您正在被重定向至 初然忆<br />
            <span class="url-box">www.imcry.vip</span>
        </p>

        <!-- 加载动画 -->
        <div class="spinner"></div>

        <div class="footer">
            若未自动跳转,请 <a href="https://www.imcry.vip/">点击此处</a>
        </div>
    </div>

    <!-- JavaScript 重定向(优先执行,浏览器兼容性最好) -->
    <script>
        (function() {
            var target = 'https://www.imcry.vip/';
            // 使用 replace 避免在浏览器历史中留下当前页
            window.location.replace(target);
        })();
    </script>

</body>
</html>

部署Pages

将该代码分别创建到 index.html 和 404.html。

博主的域名是备案过的,因此选择国内厂商的Pages服务是最优选择。

阿里云ESA的Pages有请求次数的限制,进而博主将目光转向腾讯的Edge-Pages。

测试

部署完毕后,等待全球DNS服务器刷新后,访问 https://imcry.vip

观察到页面会立即跳转至 https://www.imcry.vip