admin管理员组文章数量:1418700
My website has duplicate content as the category pages are found both with and without the category prefix. I'm not trying to strip the /category part - just trying to figure out why the pages load without it and how to stop it. Every time I google the issue it's all about removing it.
I'm using The SEO Framework Plugin - perhaps that's involved
My website has duplicate content as the category pages are found both with and without the category prefix. I'm not trying to strip the /category part - just trying to figure out why the pages load without it and how to stop it. Every time I google the issue it's all about removing it.
I'm using The SEO Framework Plugin - perhaps that's involved
Share Improve this question asked Jul 27, 2019 at 17:31 bdmasonbdmason 1011 Answer
Reset to default 0I didn't find the cause. But I was able to hack a solution into functions.php
:
add_action("wp", "disable_duplicate_categories");
function disable_duplicate_categories() {
if (is_category()) {
$urlParts = explode('/', $_SERVER["REQUEST_URI"]);
if ($urlParts[1] !== 'category') {
array_splice($urlParts, 1, 0, 'category');
$url = implode('/', $urlParts);
header("Location: ".$url,TRUE,301);
exit;
}
}
}
The unwanted pages are never linked to, so the slight delay from redirecting after some of the server code runs and calls the database is unimportant.
I have some code in the theme that's dependent on The SEO Framework, so ruling that out wasn't possible without a lot of messing about. If anybody has a clue as to why the category archives resolve without the category base please share.
本文标签: categoriesCategory pages resolving with and without category prefix
版权声明:本文标题:categories - Category pages resolving with and without category prefix 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745290825a2651782.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论