-
posts sitemaps, return 404 error, dedicated server and shared server, both are the same case, already tried the blog post tutorial to fix, but not solved
Hostinger Shared Server and OVH Dedicated server with cyberpanel
-
Hello,
I apologize for the issue you are facing with the sitemap returning a 404 error. Since you’ve already tried the blog post tutorial without success, let’s go through some additional steps that might help resolve this issue:
1. Check Permalink Structure
If you recently changed your permalink structure, ensure that your sitemap is updated accordingly. You can do this by navigating to Settings → Permalinks in your WordPress dashboard and simply clicking Save Changes to flush the permalinks.
2. Add Rewrite Rules
For both Apache and Nginx servers, you may need to add specific rewrite rules to your server configuration. Here’s how:
For Apache:
Add the following code to your
.htaccess
file:# 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
For Nginx:
Add the following code to your Nginx configuration file:
# 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
3. Exclude Sitemap from Caching
If you are using a caching plugin, ensure that the sitemap files generated by Rank Math are excluded from being cached. This can often lead to outdated or incorrect sitemap responses.
4. Check Robots Meta Tag
Ensure that your posts and pages are set to index in the robots meta tag. If they are set to noindex, they will not appear in the sitemap, which could lead to a 404 error.
You can check this by navigating to Rank Math SEO → Advanced tab in the post editing screen.
5. Flush Sitemap Cache
After making any changes, navigate to Rank Math SEO → Sitemap Settings and change the Links Per Sitemap setting, then click Save Changes. This will help flush the sitemap cache.
If these steps do not resolve the issue, please reply to this ticket with your site URL so that a human agent can assist you further. Thank you for raising this concern, and we hope to help you get it resolved soon!
Sources:
Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank MathThis 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,
Thank you for contacting us and sorry for any inconvenience that this issue might have caused.
Please try to follow the steps below and see if that works for you.
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. If the above steps don’t seem to work, kindly apply the following filter to your site.
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Here’s how you can add a filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/Once done, clear your website cache and check the sitemap again.
Let us know how it goes. Looking forward to helping you.
Thank you.
I do everything you recommended, but it does not solve, post-sitemap2.xml until the end of post-sitemap*.xml does not show. The first post-sitemap-1.xml shows, but is not complete, showing only the domain URL. Post URLs are the problem
You must be logged in to reply to this ticket.