Recently webmaster tools started showing 404 Not Found error for Sitemaps in a WordPress blog I manage, and when I checked the Sitemap, yes the sitemaps were not working, it was weird as I hadn’t changed anything on the site, everything was same from months.
I was using WordPress SEO plugin by Yoast. I checked everything and everything was working fine except the sitemap.
To check if there is a conflict between the plugins, I even disabled all the plugins but disabling the plugins didn’t work for me.
Different Users have shared different ways in order to solve the issue, I am sharing some of them.
Sitemap XML 404 Not Found in Yoast Solution
- Disable the sitemap by navigating to SEO > XML Sitemaps and uncheck the XML sitemap option and save it.
- After saving it, Enable it again and save the changes and check if the sitemap is working or not. For me, it was working.
I am not sure what was the reason for the error and how just disabling and enabling solved the issue, As I am not using any cache plugin or anything like that which might cause the problem.
Users have even suggested that resetting the permalink solved the issue for them. So, try by resetting the permalink by navigating to Settings > Permalinks.
Yoast(Developer of the Plugin) claim that the problem is not because of their plugin, It’s due to poorly coded theme or plugins you are using and advice to add the below code in your .htaccess file.
# WordPress SEO - XML Sitemap Rewrite Fix RewriteEngine On RewriteBase / RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L] RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L] RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [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 WordPress SEO - XML Sitemap Rewrite Fix
How to Edit .htaccess File
- If you are not using any security Plugin or any other plugin which controls the .htaccess file, you can edit the .htaccess file by navigating to SEO > Edit Files.
- If you are using some security plugin which changes the .htaccess file, in that case, there must be some setting in that plugin from where you can edit the .htaccess file.