[wp-trac] [WordPress Trac] #50926: Page 2 onwards of any wp-sitemap.xml URL will result in a 404 redirect

WordPress Trac noreply at wordpress.org
Wed Aug 12 07:15:07 UTC 2020


#50926: Page 2 onwards of any wp-sitemap.xml URL will result in a 404 redirect
--------------------------+------------------------------
 Reporter:  GamerZ        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Sitemaps      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by GamerZ):

 I have fixed it on my site by using redirect_canonical filter.
 {{{#!php
 <?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
 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50926#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list