How to fix 404 not found issue for rank math sitemap.xml issue

How to fix 404 not found issue for rank math sitemap.xml issue

In this post you will find how to solve the issue if you are facing the 404 not found issue for the sitemap using rank math or any othere plugins.

enable site map

First of all you have to check in any plugin that sitemap is enable
and then you have to check Https://yourstiename/?sitemap=1 check if the sitemap is loading or not.

If this URL shows an XML sitemap, then Rank Math itself is working and the problem is your server’s rewrite rules. Rank Math specifically recommends this test.

If ?sitemap=1 works

If it is working then go to your files manager plugin or public_html in the file browser then look for .htaccess file and add this code in the bottom of the file

RewriteEngine On
RewriteBase /

RewriteRule ^sitemap_index\.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 [L]

Then save that file. These are the rewrite rules recommended by Rank Math for Apache servers. But don't add them yet if you haven't tested ?sitemap=1. We should first determine exactly where the problem is.

Also check for a physical sitemap file

Some time it is happen that the sitemap is already in your public folder. So first of all we have to check it using FTP/File Manager, look inside your WordPress root: public_html/ check for the sitemap.xml file and delete that file and then check your 404 error will removed.

Clear caching for solve 404 not found issue

If you’re using something like:

  • LiteSpeed Cache
  • WP Rocket
  • W3 Total Cache
  • Cloudflare
  • Bluehost/server cache

clear the cache.

Sitemaps should also be excluded from caching because cached 404 responses can cause this exact problem.

Flush WordPress Permalinks

Go to: Settings → Permalinks Don’t change anything. Just click: Save Changes. This is one of the main fixes Rank Math recommends for a sitemap.xml 404 not found issue.

flush rewrite rules