-
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
.htaccessfile:# 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 RulesFor 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 Sitemaps3. 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 MathHello,
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
Hello,
In this case, assuming you are using the latest version of all the plugins and the themes (please update if not yet), this can be caused by a conflicting plugin/theme with Rank Math.
To determine that, please follow this troubleshooting guide:
https://rankmath.com/kb/check-plugin-conflicts/Here is a video you can follow as well: https://www.youtube.com/watch?v=FcIWRhcUP2c
Only the site admin would know, and your users won’t be affected by this troubleshooting.
Let us know how this goes.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Not solved, please take a look, because I left only Rank Math, in the same way, after clearing the cache, same error
Hello,
We would like to debug this issue further. Can you add your website’s FTP login in the Sensitive Data section of this ticket?
Looking forward to helping you with this one.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Now sensitive data has ftp details to login
Hello,
We have accessed your FTP login, but your WP admin login is no longer active. Can you please extend the login access so we can check the issue further?
Looking forward to hearing back from you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Updated
Hello,
We have located the issue. It appears that you have added a custom canonical link without the
httpsas you can see from the screenshot below:Having a mismatch with the canonical link will cause the link to not be included in the sitemap and since all of your posts have an incorrect canonical link, your sub-sitemaps are showing a page not found.
To fix this, you’ll have to remove the custom canonical URL from the posts:
Hope that helps.
You must be logged in to reply to this ticket.