4.5 KiB
4.5 KiB
22 GPT模板 Sitemap 与百度推送 URL 规范化修正 2026-05-09
1. 背景
7 日验收后继续排查 301,发现重点域名的 HTTP 头链路是:
http://domain/ -> https://domain/ -> 200http://domain/detail -> https://domain/detail -> 200
这说明 301 不是应用死循环,而是蜘蛛还在抓旧 HTTP 或旧入口。
继续核查代码和生成产物后,发现更关键的问题:
robots.txt指向https://domain/sitemap_index.xml- 页面 canonical 多数指向
https://domain/... - 但 sitemap 模板、生成逻辑、百度推送逻辑里仍有
https://www.domain/...
这会造成 domain 与 www.domain 两套规范 URL 并存,削弱收录和首页词承接。
2. 本次代码修正
只在当前 GPT 主测试源修改,不改其它 GPT 源,也不动老模板。
2.1 动态 sitemap 输出
修改:
code/app/services/SiteContext.php
动作:
/rss/so.xml动态兼容输出从https://www.{host}改为https://{host}。
2.2 GPT 模板 sitemap 文件
修改:
code/app/home/view/videoGpt1/rss/so.xmlcode/app/home/view/videoGpt1/sitemap/sitemap_index.xmlcode/app/home/view/videoGpt1/sitemap/sitemap-main.xmlcode/app/home/view/videoGpt1/sitemap/sitemap-books.xmlcode/app/home/view/videoGpt1/sitemap/sitemap-books-catalog.xmlcode/app/home/view/videoGpt1/sitemap/sitemap-chapters.xml
动作:
- sitemap 内所有站点 URL 从
https://www.{$DomainModel->d_domain}改成https://{$DomainModel->d_domain}。
2.3 后台 sitemap 生成逻辑
修改:
code/app/task/logic/VideoSiteMapLogic.php
动作:
sitemap_index.xml生成改为https://domain/...sitemap-main.xml生成改为https://domain/...sitemap-videos-*.xml生成改为https://domain/...sitemap-videos-*.txt生成改为https://domain/...video-list-*.json的href改为https://domain/...- 修复
sitemap-videos-*.txt追加写入问题:每次生成前先清空 txt,避免旧https://www.domain/...残留。
2.4 百度主动推送
修改:
code/app/task/logic/BaiduPushVideoUrlLogic.php
动作:
- 百度推送 API 的
site=从https://www.domain改为https://domain。
3. 已刷新运行产物
已重生成以下重点域名的 code/storage/SiteMap/{domain}:
zbsv3.comsdxhtgcl.comsdxtwnc.comglae.ccjxxgygy.comjingxifa.comcodohealth.comvikau.comcnzhenbang.com
抽查结果:
sitemap_index.xml输出https://domain/sitemap-main.xmlsitemap-main.xml输出https://domain/sitemap-videos-1.txt输出https://domain/...video-list-1.json的href输出https://domain/...
说明:
抽查命令里仍会看到
http://www.sitemaps.org/schemas/sitemap/0.9,这是 XML 命名空间,不是站点 URL,不影响 canonical 判断。
4. 验证
已执行:
php -l code/app/services/SiteContext.php
php -l code/app/task/logic/VideoSiteMapLogic.php
php -l code/app/task/logic/BaiduPushVideoUrlLogic.php
结果:
- 三个 PHP 文件均无语法错误。
生成命令:
php -r 'require __DIR__ . "/vendor/autoload.php"; $app = new think\App(); $app->initialize(); app\common\helper\DomainSitemapGenerationHelper::generateNow(["zbsv3.com","sdxhtgcl.com","sdxtwnc.com","glae.cc","jxxgygy.com","jingxifa.com","codohealth.com","vikau.com","cnzhenbang.com"]);'
结果:
- 4 页 sitemap/video-list 全部生成完成。
- 结束时间:
2026-05-09 10:49:49
5. SEO 影响判断
这次修正解决的是 URL 规范化问题,不是直接加词。
预期影响:
- 减少
www与非www的 URL 信号分散。 - 让 robots、canonical、sitemap、百度推送保持同一规范版本。
- 后续百度抓取里
http -> https的 301 不会立刻归零,但www相关的分裂入口会逐步减少。 - 对
glae/jxxgygy/jingxifa/codohealth的收录转词更有利。
明天复查:
2026-05-10蜘蛛日志里重点域名的 Baidu301是否下降。sitemap-videos-*.txt是否继续保持非 www。- 百度推送摘要里
site=是否不再出现https://www.domain。 - 爱站
pc_keyword_count是否从0恢复到>=2。
6. 当前结论
本次属于 7 日失败后的必要技术纠偏。
前面的问题不是“AI 文案没用”,而是 URL 规范信号有分裂:页面告诉搜索引擎看非 www,sitemap/推送却给了 www。现在当前 GPT 主测试源已经统一到非 www,下一步看蜘蛛日志中的 301 和爱站词恢复情况。