#50926 closed defect (bug) (duplicate)
Page 2 onwards of any wp-sitemap.xml URL will result in a 404 redirect
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Sitemaps | Keywords: | |
Focuses: | Cc: |
Description
Works: https://lesterchan.net/wp-sitemap-posts-page-1.xml
Broken: https://lesterchan.net/wp-sitemap-posts-page-2.xml
Notice that the broken URL is redirected to https://lesterchan.net/wp-sitemap-posts-page-2.xml/page/2
I suspect it is due to Line 475 to Line 477 of wp-includes/canonical.php
As after removing the lines it works
<?php if ( $paged > 1 ) { $addl_path .= user_trailingslashit( "$wp_rewrite->pagination_base/$paged", 'paged' ); }
Change History (4)
#1
in reply to:
↑ description
@
5 years ago
#2
@
5 years ago
I have fixed it on my site by using redirect_canonical filter.
<?php function lesterchan_redirect_canonical( string $redirect_url, string $requested_url ) { if ( strpos( $requested_url, 'wp-sitemap' ) !== false ) { return $requested_url; } return $redirect_url; } add_filter( 'redirect_canonical', 'lesterchan_redirect_canonical', 10, 2 );
Note: See
TracTickets for help on using
tickets.
Works: https://lesterchan.net/wp-sitemap-posts-post-1.xml
Broken: https://lesterchan.net/wp-sitemap-posts-post-2.xml
Works: https://lesterchan.net/wp-sitemap-taxonomies-post_tag-1.xml
Broken: https://lesterchan.net/wp-sitemap-taxonomies-post_tag-2.xml
Replying to GamerZ: