Hello,
I apologize for the inconvenience you are facing with your multilingual website’s sitemap. It seems that extra URLs are being added to the sitemap, causing 404 errors.
To resolve this issue, you can add the following piece of code anywhere in your theme’s functions.php file:
add_filter( 'rank_math/sitemap/url', function( $url, $object ) {
if ( strpos( $url, '/fr/' ) !== false ) {
return $url;
}
return '';
}, 10, 2 );
This code snippet will help exclude the unwanted URLs from the sitemap that are causing 404 errors. Please add this code to your theme’s functions.php file.
If you need further assistance or have any other questions, feel free to ask.
Thank you for reaching out and providing the screenshot.
Sources:
Multilingual SEO with Rank Math SEO & WPML » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.
Hello,
For initial troubleshooting, please follow these steps to flush your sitemap cache:
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp
2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/
3. Disable the transient cache for the sitemap by applying this filter. This will make sure that your XML sitemap always reflects the latest changes on your site:
/**
* Filter if XML sitemap transient cache is enabled.
*
* @param boolean $unsigned Enable cache or not, defaults to true
*/
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
If you’re not sure how to add this code, you can follow this guide:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how this goes.