#50926 closed defect (bug) (duplicate)
Page 2 onwards of any wp-sitemap.xml URL will result in a 404 redirect
| Reported by: | GamerZ | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Sitemaps | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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
@
6 years ago
Version 0, edited 6 years ago by
(next)
#2
@
6 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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: