fix: correct baidu crawl configuration

This commit is contained in:
rain
2026-07-20 10:55:20 +08:00
parent fddb0d3607
commit 2228ac170f
3 changed files with 116 additions and 20 deletions
+23 -9
View File
@@ -1,26 +1,40 @@
# 对所有搜索引擎生效
User-agent: *
# 允许抓取网站所有公开页面
Allow: /
# 屏蔽登录/注册/用户中心页面
# 登录注册用户中心
Disallow: /login.html
Disallow: /reg.html
Disallow: /repwd.html
Disallow: /usercenter.html
Disallow: /html/login.html
Disallow: /html/reg.html
Disallow: /html/repwd.html
Disallow: /html/usercenter.html
# 屏蔽财务相关页面
# 财务页面
Disallow: /chongzhi.html
Disallow: /tixian.html
Disallow: /tixianlist.html
Disallow: /jine.html
Disallow: /html/chongzhi.html
Disallow: /html/tixian.html
Disallow: /html/tixianlist.html
Disallow: /html/jine.html
# 屏蔽收藏/分销/推广相关页面
# 用户收藏分销推广和发布页面
Disallow: /mianfeishoucang.html
Disallow: /zhuanjiashoucang.html
Disallow: /wodefenxiao.html
Disallow: /fenxiao.html
Disallow: /tuiguang.html
Disallow: /fabumianfeiwenzhang.html
Disallow: /fufei.html
Disallow: /apply.html
Disallow: /html/mianfeishoucang.html
Disallow: /html/wodefenxiao.html
Disallow: /html/fenxiao.html
Disallow: /html/tuiguang.html
Disallow: /html/fabumianfeiwenzhang.html
Disallow: /html/fufei.html
Disallow: /html/apply.html
# 提交 sitemap,搜索引擎根据 sitemap 快速抓取
Sitemap: https://3d.3dyjs.cn/sitemap.xml
Sitemap: https://www.scs8888.cn/sitemap.xml
+1 -11
View File
@@ -1,18 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://3d.3dyjs.cn/</loc>
<loc>https://www.scs8888.cn/</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://3d.3dyjs.cn/zhuanjia.html</loc>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://3d.3dyjs.cn/kaijiang.html</loc>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
+92
View File
@@ -0,0 +1,92 @@
const fs = require("fs");
function read(path) {
return fs.readFileSync(path, "utf8");
}
function assert(condition, message) {
if (!condition) throw new Error(message);
}
const robots = read("robots.txt");
const sitemap = read("sitemap.xml");
const index = read("html/index.html");
const article = read("html/mianfei.html");
const commonUtil = read("utils/CommonUtil.js");
assert(!robots.includes("3d.3dyjs.cn"), "robots should not reference the old domain");
assert(!sitemap.includes("3d.3dyjs.cn"), "sitemap should not reference the old domain");
assert(
robots.includes("Sitemap: https://www.scs8888.cn/sitemap.xml"),
"robots should advertise the production sitemap",
);
const sitemapLocations = Array.from(sitemap.matchAll(/<loc>([^<]+)<\/loc>/g), (match) => match[1]);
assert(sitemapLocations.length === 1, "static sitemap should contain only the confirmed homepage");
assert(
sitemapLocations[0] === "https://www.scs8888.cn/",
"static sitemap homepage should use the canonical production origin",
);
[
"login",
"reg",
"usercenter",
"chongzhi",
"tixian",
"fabumianfeiwenzhang",
"fufei",
].forEach((privateRoute) => {
assert(!sitemap.includes(privateRoute), `private route must not appear in sitemap: ${privateRoute}`);
});
assert(/<meta\s+name="description"/i.test(index), "homepage description metadata missing");
assert(
/<link\s+rel="canonical"\s+href="https:\/\/www\.scs8888\.cn\/"/i.test(index),
"homepage canonical metadata missing",
);
assert(
index.includes('<h1 class="seo-heading">神彩算彩票数据分析与免费预测文章</h1>'),
"homepage crawlable H1 missing",
);
assert(
index.includes("开奖数据、走势分析和免费文章"),
"homepage crawlable site description missing",
);
assert(/<meta\s+name="description"/i.test(article), "article default description metadata missing");
assert(
/<meta\s+name="robots"\s+content="index, follow"/i.test(article),
"article robots metadata missing",
);
assert(
/<link\s+id="canonicalUrl"\s+rel="canonical"/i.test(article),
"article canonical hook missing",
);
assert(article.includes("function updateArticleSeo(data)"), "article SEO updater missing");
assert(article.includes("updateArticleSeo(data);"), "article renderer should update SEO metadata");
assert(
article.includes("https://www.scs8888.cn/mianfei/"),
"article canonical should use the public pretty URL",
);
assert(
/return `\/mianfei\/\$\{id\}\.html`/.test(commonUtil),
"CommonUtil.freeArticleHref should own the public article URL",
);
const deploymentDocPath = "docs/baidu-indexing-deployment.md";
assert(fs.existsSync(deploymentDocPath), "backend deployment handoff missing");
const deploymentDoc = read(deploymentDocPath);
[
"/mianfei/{id}.html",
"404",
"301",
"动态 sitemap",
"Baiduspider",
"预渲染",
].forEach((requiredText) => {
assert(deploymentDoc.includes(requiredText), `deployment handoff missing: ${requiredText}`);
});
console.log("SEO indexing checks passed");