How to Fix WordPress Sitemap 404 Errors
How to resolve How to Fix WordPress Sitemap 404 Errors?
To fix a WordPress XML sitemap 404 error, navigate to wp-admin > Settings > Permalinks and click 'Save Changes' to flush rewrite rules. If using Nginx, add a rewrite rule for virtual sitemaps; in Apache, ensure your .htaccess includes default WordPress rewrite blocks.
Symptoms & Diagnostic Indicators
Visitors and search crawlers encounter an HTTP 404 Not Found error when accessing sitemap.xml, sitemap_index.xml, or sub-sitemaps.
Common Root Causes
Stale WordPress Rewrite Rules
WordPress dynamically generates sitemaps in memory via rewrite endpoints. When plugins update or permalinks change without flushing the internal rewrite cache, the endpoint returns 404.
curl -ILs https://example.com/sitemap.xml | grep -i 'HTTP/'Missing Web Server Directives
On Nginx servers, virtual XML requests may be treated as physical files on disk unless pass-through rewrite rules point to index.php.
Step-by-Step Fix
Hard Flush Rewrite Rules via WP-CLI or Admin
Save permalinks in wp-admin, or run WP-CLI command from your server terminal to flush rewrite rules immediately.
wp rewrite flush --hardAdd Nginx XML Sitemap Pass-Through Rule
If using Nginx, ensure virtual XML sitemaps route to index.php instead of looking for physical files on the filesystem.
location ~ ([^/]*)sitemap(.*)\.xml$ {
rewrite ^/sitemap(_index)?\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}Prevention & Verification Checklist
- Always flush rewrite rules after activating or deactivating SEO plugins
- Verify .htaccess permissions allow write access for WordPress core (chmod 644)
- Ensure caching plugins exclude /sitemap*.xml from static disk caching
Never Experience Sitemap 404s Again
SearchNexa Connector pre-compiles clean, zero-bloat XML sitemaps with automated rewrite healing.
Download SearchNexa Free