url rewriting - Wordpress Redirecting Non Category Pages pagennn to their Canonical URLs

I seemingly to have a strange issue I have found in almost every other Wordpress site.Suppose, you have set your Blog ho

I seemingly to have a strange issue I have found in almost every other Wordpress site.

Suppose, you have set your Blog home to a static WP page /myhome. And you have a separate page for blog /blog.

Now, this works fine and should be:

/blog
/blog/page/2
/blog/page/3
/blog/page/4

But, for all other pages, e.g. /about-us, these links also work:

/about-us/page/2
/about-us/page/3
/about-us/page/4

And show the content of the /about-us page.

My problem is that /about-us/page/2 should ideally redirect to /about-us (it's canonical URL) since there are no paginations in any other page except the /blog.

What am I missing there ? This seems to happen on almost all sites I have checked and is really frustrating from SEO point of view.

I seemingly to have a strange issue I have found in almost every other Wordpress site.

Suppose, you have set your Blog home to a static WP page /myhome. And you have a separate page for blog /blog.

Now, this works fine and should be:

/blog
/blog/page/2
/blog/page/3
/blog/page/4

But, for all other pages, e.g. /about-us, these links also work:

/about-us/page/2
/about-us/page/3
/about-us/page/4

And show the content of the /about-us page.

My problem is that /about-us/page/2 should ideally redirect to /about-us (it's canonical URL) since there are no paginations in any other page except the /blog.

What am I missing there ? This seems to happen on almost all sites I have checked and is really frustrating from SEO point of view.

Share Improve this question asked Aug 20, 2015 at 13:54 shamittomarshamittomar 1134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This is by design and intentional. WordPress rewrites have become increasingly complex over the years, and many plugins utilise the page endpoint for a page (usually with a template and custom query) - redirecting introduces a potential world of pain.

Long story short, it doesn't matter anyway. WordPress adds <link rel="canonical /> for pages, so no need to worry over duplicate content.

Update: For localised situations where you want to disregard the potential risks, this will canonicalize all page URLS - note that it does not check if a page is actually paginated (i.e. with the <!--nextpage--> quicktag) and will break this feature if you use it.

function wpse_199180_canonical_pages( $wp ) {
    if ( ! is_admin() && is_page() && isset( $wp->query_vars['paged'] ) ) {
        wp_redirect( get_permalink( get_queried_object() ), 301 );
        exit;
    }
}

add_action( 'wp', 'wpse_199180_canonical_pages' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744854123a4597303.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信