How to Fix Rank Math Sitemap 404 Error (WP Super Cache & Cloudflare)

Short answer: A Rank Math sitemap that shows a 404 page is usually caused by one of four things: a stale sitemap cache, permalinks that need refreshing, a caching plugin or CDN that stored the sitemap, or missing rewrite rules on the server. Work through the steps below in order and test /sitemap_index.xml after each one.

Checked against Rank Math’s own documentation on 19 October 2026. Menu names in WP Super Cache and Cloudflare change over time, so if a label looks slightly different on your screen, look for the closest match.

Is your sitemap really returning a 404?

Open your sitemap in a private (incognito) window. The default Rank Math address is:

https://yourdomain.com/sitemap_index.xml

Use incognito on purpose. If you are logged in to WordPress, your browser may show a different result than Google or a visitor would see. You can find the exact sitemap address under Rank Math SEO → Sitemap Settings.

Rank Math sitemap_index.xml showing a 404 page on a WordPress site
A theme 404 page (“This page doesn’t seem to exist”) shown at /sitemap_index.xml. A real sitemap shows a list of XML links instead.

If you see your theme’s “page not found” screen like the one above, WordPress did not hand the request to Rank Math. The steps below fix that.

Common causes at a glance

  • Old sitemap cache inside Rank Math.
  • Permalink rules that were not refreshed after a migration, plugin change or permalink change.
  • A caching plugin or CDN (WP Super Cache, Cloudflare and similar) that stored or blocked the sitemap.
  • Missing Apache or Nginx rewrite rules. Rank Math lists this as a server-level cause.
  • Pages set to noindex. Rank Math says noindex content is left out of the sitemap, which can lead to an empty or missing sitemap.

Step 1: Flush the Rank Math sitemap cache

  1. Go to Rank Math SEO → Sitemap Settings.
  2. Change the Links Per Sitemap number (for example, from 200 to 201).
  3. Click Save Changes at the bottom.

Rank Math’s guide uses this change to force the sitemap to rebuild. You can change the number back later.

Step 2: Re-save your permalinks

  1. Go to Settings → Permalinks.
  2. Do not change anything. Just click Save Changes.

This makes WordPress rebuild its URL rules. Test your sitemap in incognito. If it loads, you are done. If not, continue.

Step 3: Stop WP Super Cache from caching your sitemap

Caching plugins are meant to speed up pages, but a sitemap should always be fresh. Rank Math recommends excluding sitemap files from caching.

  1. Go to Settings → WP Super Cache → Advanced.
  2. Scroll to Rejected URL Strings.
  3. Add a new line with the word sitemap. Keep the lines that are already there.
  4. Click Save Strings.
WP Super Cache Rejected URL Strings box with the word sitemap added
The word “sitemap” added on its own line under the default entries.

WP Super Cache describes this box as strings that stop a page from being cached if the string appears anywhere in the URL. So the word sitemap covers sitemap_index.xml, post-sitemap.xml and similar files.

Rank Math’s own guide suggests longer patterns instead. Use them if the short word does not work for you:

sitemap?\.xml?
[a-z0-9_\-]*sitemap[a-z0-9_\-]*.(\xml|xsl)?
([az0-9_\-]*?)sitemap([a-z0-9_\-]*)?.xml

After saving, clear the existing cache from the WP Super Cache settings page, then test again in incognito.

Step 4: Tell Cloudflare not to cache .xml files

Rank Math notes that Cloudflare does not normally cache sitemaps. This step is only needed if you suspect Cloudflare is serving an old or wrong copy, or if you have other caching rules that may catch XML files.

Rank Math’s guide uses a Page Rule set to Cache Level: Bypass. Cloudflare’s newer way to do the same job is a Cache Rule, which is what is shown here:

  1. Log in to Cloudflare and select your website.
  2. Open the Cache Rules section (usually under Caching → Cache Rules or Rules) and create a new rule.
  3. Give it a clear name, for example Bypass XML Sitemaps.
  4. Choose Custom filter expression.
  5. Set Field to URI Path, Operator to ends with, and Value to .xml.
  6. Under Cache eligibility, choose Bypass cache.
  7. Click Deploy.
Cloudflare Cache Rule with URI Path ends with .xml and Bypass cache selected
The expression preview should read: (ends_with(http.request.uri.path, “.xml”))
Cloudflare Cache Rule screen with Bypass cache selected and the Deploy button
Choose Bypass cache, then press Deploy once the rule validation passes.

Afterwards, purge Cloudflare’s cache so old copies are removed. Cloudflare offers purge by URL, by host, by prefix and “purge everything”. Purging only your sitemap URL is the most careful choice.

Note: this rule matches only paths that end in .xml. Rank Math’s .xsl stylesheet file is not matched, which is normally fine.

Mistake to avoid: pasting the whole expression into the Value box

The Value box expects only the text to match, such as .xml. If you paste a full expression like ends_with(http.request.uri.path, ".xml") into it, Cloudflare wraps your text inside another expression and the rule becomes wrong, as shown below.

Cloudflare rule where the full expression was pasted into the Value box, creating a doubled expression
The Expression Preview shows ends_with(…) repeated inside itself. Delete the Value box text and type only .xml.

Step 5: Check the server rewrite rules (Apache or Nginx)

If the sitemap still returns 404, the server may not be sending sitemap requests to WordPress. Rank Math says it may show a notice in Sitemap Settings when Nginx blocks sitemap creation.

Apache (.htaccess). Back up your .htaccess file first, then add this at the end:

# START of Rank Math Sitemap Rewrite Rules
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]
# END of Rank Math Sitemap Rewrite Rules

Nginx. Add these rules to the server configuration. If you are not sure how, ask your host:

# START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
rewrite ^/([a-z]+)?-sitemap\.xsl$ /index.php?xsl=$1 last;
# END Nginx Rewrites for Rank Math Sitemaps

Rules copied from Rank Math’s sitemap 404 guide. Check that guide for any newer version before you paste them.

Step 6: Check that your content is set to index

Open a post or page and go to Rank Math SEO → Advanced in the editor. Make sure the robots setting is Index, then click Update. Rank Math says content set to noindex is excluded from the sitemap.

Last resort: turn off Rank Math’s sitemap caching

If nothing above works, Rank Math documents a filter that switches off its built-in sitemap cache. This needs code, so use a code snippets plugin or a child theme and keep a backup:

add_filter( 'rank_math/sitemap/enable_caching', '__return_false' );

How to confirm it is fixed

  1. Open /sitemap_index.xml in an incognito window. You should see a list of sitemap links (post, page, category and so on), not a 404 page.
  2. Click one child sitemap, such as post-sitemap.xml, to check it loads too.
  3. In Google Search Console, go to Sitemaps, enter sitemap_index.xml and submit it.

Google may take some time to read the sitemap. A “Couldn’t fetch” or pending status right after submitting does not always mean a problem, so check again after a day or two before changing settings again.

Troubleshooting table

What you seeLikely causeWhat to try
404 only when logged outPage cache or CDNSteps 3 and 4, then purge caches
404 for every .xml fileMissing rewrite rulesSteps 2 and 5
Main sitemap loads, one child sitemap is 404Stale sitemap cache or no indexable content of that typeSteps 1 and 6
Sitemap looks old after publishingCached copySteps 3 and 4
Fixed, then breaks againRule order, or old copies not purgedRe-check the rule order and the Rejected URL Strings box

Common mistakes

  • Testing while logged in. Always use incognito, or you may not see what visitors see.
  • Replacing the default WP Super Cache lines. Add sitemap on a new line. Do not delete the existing entries.
  • Forgetting to purge. A new rule does not remove copies that were already cached.
  • Using the wrong sitemap address. Rank Math uses sitemap_index.xml. Addresses like /sitemap.xml may not exist, depending on your setup.
  • Running two sitemaps. If another SEO plugin or your theme also makes a sitemap, they can clash. Keep one active.
  • Editing server files without a backup. Save a copy of .htaccess before any change.

Frequently asked questions

Why does my Rank Math sitemap show 404 after I changed permalinks?

WordPress needs to rebuild its rewrite rules. Save the permalinks page again (Step 2) and flush the sitemap cache (Step 1).

Do I need to exclude the sitemap in both WP Super Cache and Cloudflare?

Not always. WP Super Cache is the first place to check. Rank Math says Cloudflare does not normally cache sitemaps, so do the Cloudflare step only if the problem remains.

Is a 404 sitemap bad for SEO?

A sitemap helps Google find your pages, but it is not the only way. Google can still find pages through links. Fix the 404 anyway so you can monitor indexing in Search Console.

Can I use this fix for Yoast or other sitemap plugins?

The ideas (refresh permalinks, exclude sitemaps from caching, check rewrite rules) are similar. The exact addresses and settings are different, so check that plugin’s own guide.

Sources

Share this post:
WhatsAppFacebookXLinkedInTelegram
Scroll to Top