|
admin
發表於 2021-12-5 23:06:27
Discuz X系列論壇在帖子頁增加了“canonical”標籤,但是首頁、版塊頁面沒有,這裡給大家公開一下實現方法:
論壇首頁:
修改文件路徑:/source/module/forum/forum_index.php
添加代碼:
- /**
- * [Discuz!] 給首頁與分區版塊加上canonical網址規範化唯一權威標籤.
- */
- $_G['setting']['seohead'] .= '<link href="'.$_G['siteurl'].'" rel="canonical" />';
[color=rgb(51, 51, 51) !important]複製代碼
版塊頁面:
修改文件路徑:/source/module/forum/forum_forumdisplay.php
添加代碼:
- /**
- * [Discuz!] 給版塊加上canonical網址規範化唯一權威標籤.
- */
- $_GET['extra'] = $_GET['extra'] ? rawurlencode($_GET['extra']) : '';
- if(@in_array('forum_forumdisplay', $_G['setting']['rewritestatus'])) {
- $canonical = rewriteoutput('forum_forumdisplay', 1, '', $_G['fid'], 1, '', '');
- } else {
- $canonical = 'https://bbs.aladedalu.com/forum.php?mod=forumdisplay&fid='.$_G['fid'];
- }
- $_G['setting']['seohead'] .= '<link href="'.$_G['siteurl'].$canonical.'" rel="canonical" />';
- $_G['forum_tagscript'] = '';
[color=rgb(51, 51, 51) !important]複製代碼
實現效果:
- <link href="https://bbs.aladedalu.com/" rel="canonical" />
[color=rgb(51, 51, 51) !important]複製代碼
|
|
|
|
|
|
|
|