fix(seo): normalize GPT sitemap push URLs

This commit is contained in:
www
2026-05-09 11:09:00 +08:00
parent 04242363a8
commit b764e7555d
14 changed files with 713 additions and 30 deletions

View File

@@ -0,0 +1,146 @@
# 22 GPT模板 Sitemap 与百度推送 URL 规范化修正 2026-05-09
## 1. 背景
7 日验收后继续排查 `301`,发现重点域名的 HTTP 头链路是:
- `http://domain/ -> https://domain/ -> 200`
- `http://domain/detail -> https://domain/detail -> 200`
这说明 `301` 不是应用死循环,而是蜘蛛还在抓旧 HTTP 或旧入口。
继续核查代码和生成产物后,发现更关键的问题:
1. `robots.txt` 指向 `https://domain/sitemap_index.xml`
2. 页面 canonical 多数指向 `https://domain/...`
3. 但 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.xml`
- `code/app/home/view/videoGpt1/sitemap/sitemap_index.xml`
- `code/app/home/view/videoGpt1/sitemap/sitemap-main.xml`
- `code/app/home/view/videoGpt1/sitemap/sitemap-books.xml`
- `code/app/home/view/videoGpt1/sitemap/sitemap-books-catalog.xml`
- `code/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`
动作:
1. `sitemap_index.xml` 生成改为 `https://domain/...`
2. `sitemap-main.xml` 生成改为 `https://domain/...`
3. `sitemap-videos-*.xml` 生成改为 `https://domain/...`
4. `sitemap-videos-*.txt` 生成改为 `https://domain/...`
5. `video-list-*.json``href` 改为 `https://domain/...`
6. 修复 `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.com`
- `sdxhtgcl.com`
- `sdxtwnc.com`
- `glae.cc`
- `jxxgygy.com`
- `jingxifa.com`
- `codohealth.com`
- `vikau.com`
- `cnzhenbang.com`
抽查结果:
- `sitemap_index.xml` 输出 `https://domain/sitemap-main.xml`
- `sitemap-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. 验证
已执行:
```bash
php -l code/app/services/SiteContext.php
php -l code/app/task/logic/VideoSiteMapLogic.php
php -l code/app/task/logic/BaiduPushVideoUrlLogic.php
```
结果:
- 三个 PHP 文件均无语法错误。
生成命令:
```bash
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 规范化问题,不是直接加词。
预期影响:
1. 减少 `www` 与非 `www` 的 URL 信号分散。
2. 让 robots、canonical、sitemap、百度推送保持同一规范版本。
3. 后续百度抓取里 `http -> https` 的 301 不会立刻归零,但 `www` 相关的分裂入口会逐步减少。
4.`glae/jxxgygy/jingxifa/codohealth` 的收录转词更有利。
明天复查:
1. `2026-05-10` 蜘蛛日志里重点域名的 Baidu `301` 是否下降。
2. `sitemap-videos-*.txt` 是否继续保持非 www。
3. 百度推送摘要里 `site=` 是否不再出现 `https://www.domain`
4. 爱站 `pc_keyword_count` 是否从 `0` 恢复到 `>=2`
## 6. 当前结论
本次属于 7 日失败后的必要技术纠偏。
> 前面的问题不是“AI 文案没用”,而是 URL 规范信号有分裂:页面告诉搜索引擎看非 wwwsitemap/推送却给了 www。现在当前 GPT 主测试源已经统一到非 www下一步看蜘蛛日志中的 301 和爱站词恢复情况。