From bd073c6795481bc51e144ed48a1e656eaa0a0c20 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 15 Apr 2026 16:06:43 +0800 Subject: [PATCH] fix id-first deep links for videoGpt1 seo --- code/app/common/helper/DomainSpiderMdRunHelper.php | 4 ++-- code/app/common/helper/SiteStyle.php | 9 +++------ code/app/home/view/videoGpt1/video/getVideoPlayUrl.html | 6 +++--- code/app/services/VideoService.php | 8 +++++--- code/app/task/logic/VideoSiteMapLogic.php | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/code/app/common/helper/DomainSpiderMdRunHelper.php b/code/app/common/helper/DomainSpiderMdRunHelper.php index 91e60fa..8e417b7 100644 --- a/code/app/common/helper/DomainSpiderMdRunHelper.php +++ b/code/app/common/helper/DomainSpiderMdRunHelper.php @@ -456,7 +456,7 @@ class DomainSpiderMdRunHelper 'detail', '详情页', (string)$row['v_name'], - self::absoluteUrl($host, $urlBuilder->detail((string)$row['v_name_en'], (int)$row['v_id'])), + self::absoluteUrl($host, $urlBuilder->detail('', (int)$row['v_id'])), 'detail' ); @@ -488,7 +488,7 @@ class DomainSpiderMdRunHelper 'forge', '详情泛链接', $forgeKeyword, - self::absoluteUrl($host, $urlBuilder->detailForge((string)$row['v_name_en'], (int)$row['v_id'], $forgeId)), + self::absoluteUrl($host, $urlBuilder->detailForge('', (int)$row['v_id'], $forgeId)), 'detail_forge' ); } diff --git a/code/app/common/helper/SiteStyle.php b/code/app/common/helper/SiteStyle.php index debc305..80ce975 100644 --- a/code/app/common/helper/SiteStyle.php +++ b/code/app/common/helper/SiteStyle.php @@ -1867,15 +1867,12 @@ class SiteStyle */ private static function guessDetailUrlFromVideo(array $arrVideo): string { - $strSlug = (string)($arrVideo['v_name_en'] ?? $arrVideo['v_slug'] ?? $arrVideo['slug'] ?? ''); $intId = (int)($arrVideo['v_id'] ?? 0); - if (!empty($strSlug) && $intId > 0) { - // 你当前详情 URL 示例:/voddetail/qian-long-zai-tian-247979 - return '/voddetail/' . $strSlug . '-' . $intId; - } if ($intId > 0) { - return '/voddetail/' . $intId; + // Keep canonical stable on id-first path. Video pages resolve by v_id, + // while slug is only for presentation and may drift over time. + return '/voddetail/-' . $intId; } return ''; } diff --git a/code/app/home/view/videoGpt1/video/getVideoPlayUrl.html b/code/app/home/view/videoGpt1/video/getVideoPlayUrl.html index 4e8a16a..17f1e6a 100644 --- a/code/app/home/view/videoGpt1/video/getVideoPlayUrl.html +++ b/code/app/home/view/videoGpt1/video/getVideoPlayUrl.html @@ -30,10 +30,10 @@ {block name="description"}{site:seotkd code="description" page="play" /}{/block} {block name="head"} - + {if $Request.route.intVId } - + {/if} @@ -214,4 +214,4 @@ -{/block} \ No newline at end of file +{/block} diff --git a/code/app/services/VideoService.php b/code/app/services/VideoService.php index f83595e..98a16da 100644 --- a/code/app/services/VideoService.php +++ b/code/app/services/VideoService.php @@ -82,7 +82,9 @@ class VideoService $strTmpCode = $this->SiteContext->TemplatesModel['t_code']; if ($strTmpCode == 'videoGpt1') { - return $this->SiteContext->UrlBuilder->detail($strPinYin, $intVId); + // videoGpt1 runtime resolves detail data by v_id. + // Use id-first urls to avoid stale slug drift creating dead deep links. + return $this->SiteContext->UrlBuilder->detail('', $intVId); } else { $strKey = 'VIDEO_INFO_URL'; $strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [ @@ -106,7 +108,7 @@ class VideoService $strTmpCode = $this->SiteContext->TemplatesModel['t_code']; if ($strTmpCode == 'videoGpt1') { - return $this->SiteContext->UrlBuilder->detailForge($strPinYin, $intVId, $intVForgeId); + return $this->SiteContext->UrlBuilder->detailForge('', $intVId, $intVForgeId); } else { $strKey = 'FORGE_VIDEO_INFO_URL'; $strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [ @@ -132,7 +134,7 @@ class VideoService $strTmpCode = $this->SiteContext->TemplatesModel['t_code']; if ($strTmpCode == 'videoGpt1') { - return $this->SiteContext->UrlBuilder->play($strPinYin, $intVId, $strPlayType, $intPlayIndex); + return $this->SiteContext->UrlBuilder->play('', $intVId, $strPlayType, $intPlayIndex); } else { $strKey = 'VIDEO_PLAY_URL'; $strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [ diff --git a/code/app/task/logic/VideoSiteMapLogic.php b/code/app/task/logic/VideoSiteMapLogic.php index ba1b67a..66164d1 100644 --- a/code/app/task/logic/VideoSiteMapLogic.php +++ b/code/app/task/logic/VideoSiteMapLogic.php @@ -189,8 +189,8 @@ EOF; $strAction = ""; $arrArgs = [ 'intVId' => $Video->v_id, - 'strPinYin' => $Video->v_name_en, - 'strPinyin' => $Video->v_name_en, + 'strPinYin' => '', + 'strPinyin' => '', ]; if ($arrUrlFamily && !empty($arrUrlFamily)) {