Incorrect trailing slash included in sitemap URLs

#4103
  • Resolved FTF
    Rank Math free

    Unlike most WordPress websites, our client’s install is setup to not include trailing slashes for all URLs.

    The RankMath plugin creates multiple sitemaps. The post sitemap is correctly configured, no trailing slash is added to the end of the URL.

    All of the other sitemaps – pages, attorneys, and locations – have URLs with a trailing slash, thus creating a 301 redirect.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Please add the following filter to your theme’s functions.php file to remove the trailing slash from the URLs:

    add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
    	$url['loc'] = untrailingslashit( $url['loc'] );
      return $url;
    }, 10, 3 );

    I hope this info helps. Thank you.

    ​​​​​​​

    FTF
    Rank Math free

    Thank you!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Incorrect trailing slash included in sitemap URLs’ is closed to new replies.