How to Fix Yoast’s WordPress SEO Sitemap 404 Error

WordPress SEO Sitemap 404 Error

Having been downloaded over 1 million instances, WordPress search engine optimization (SEO) by Yoast plugin is by far the most effective and most full search engine optimization plugin for WordPress. Whereas it has given us no points prior to now, for some customers it has been an ache. Not too long ago certainly one of our shoppers bumped into the problem of getting a 404 error for his or her sitemaps generated by Yoast’s WordPress search engine optimization plugin. After making an attempt at a number of issues, we have been in a position to determine the answer. In this article, we'll present your tips on how to repair the sitemap 404 error in WordPress search engine optimization plugin by Yoast.

Replace: It will be important that you simply perceive that this problem is most probably attributable to poorly coded themes perform or plugin. Yoast’s plugin works fantastic on our websites. Simply wished to be very clear about this.

The very first thing it is best to strive is to open your .htaccess file (you'll be able to really do that from WordPress search engine optimization plugin > Edit Recordsdata possibility) and easily add the next code in there:

# WordPress SEO – XML Sitemap Rewrite Fix

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]

# END WordPress SEO – XML Sitemap Rewrite Fix

For most individuals, this fastened the problem. Somebody reported that whereas this code fastened the problem, the web page was nonetheless sending the 404 error response header which meant that Google Site owners device couldn’t discover it. Nicely in our consumer’s case, the above answer did NOT repair the problem.

Whereas not most popular, we had no selection however to edit the core plugin records data to repair the problem. As prompt by hadjedj.vincent, we edited the class-sitemaps.php positioned in “/wp-content/plugins/wordpress-seo/inc/class-sitemaps.php”.

It's essential to have a look at the perform init() code and make that part seem like this:

* Initialize sitemaps. Add sitemap rewrite rules and query var
function init() {
global $wp_rewrite;
$GLOBALS[‘wp']->add_query_var( ‘sitemap' );
$GLOBALS[‘wp']->add_query_var( ‘sitemap_n' );
add_rewrite_rule( ‘sitemap_index.xml$', ‘index.php?sitemap=1', ‘top' );
add_rewrite_rule( ‘([^/]+?)-sitemap([0-9]+)?.xml$', ‘index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', ‘top' );

Principally what we're doing is including the worldwide $wp_rewrite; at the beginning that's already there and including flush_rules after the code. By including this within the plugin, it appears to repair the 404 error problems on our consumer’s web site. We do not know why Yoast is just not doing this by default, however, plainly fairly a number of customers are having this sitemap 404 error problem. This problem is defined within the feedback.

Replace: As a few of our customers reported that after making use of the above repair, they nonetheless wanted to uncheck the sitemap possibility within the Yoast’s search engine optimization plugin and save their settings. After that re-checking the sitemap’s possibility fastened the error for them.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top