|
Discuz X系列论坛在帖子页增加了“canonical”标签,但是首页、版块页面没有,这里给大家公开一下实现方法:
论坛首页:
修改文件路径:/source/module/forum/forum_index.php
添加代码:
- /**
- * [Discuz!] 给首页与分区版块加上canonical网址规范化唯一权威标签.
- */
- $_G['setting']['seohead'] .= '<link href="'.$_G['siteurl'].'" rel="canonical" />';
复制代码
版块页面:
修改文件路径:/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'] = '';
复制代码
实现效果:
- <link href="https://bbs.aladedalu.com/" rel="canonical" />
复制代码
相关教程:
Discuz论坛网址后面带“?adfwkey=”乱码小尾巴的解决方法 |
|