How to Fix Yoasts WordPress SEO Sitemap 404 Error

In this article, we will show you how to fix Yoast’s WordPress SEO sitemap 404 error.

All those who have a WordPress website, it is very likely that they have already installed the most popular plugin for on-page SEO known as Yoast SEO.

It has over 3 million active installs and a high average rating. With so many installs, you would expect it to have no technical issue especially because it keeps updating the version regularly.

But there are many users who are facing a very typical technical glitch of site 404 error.

Unlike other plugins where users generally uninstall that completely if there is any glitch, the same cannot hold for Yoast SEO.

The reason is there is no other plugin like it in the market, and on-page SEO is absolutely necessary for ranking the content better.

It is important to understand that this sitemap 404 error could well be due to other functions and plugins because Yoast SEO claims to have solved the technical glitch in their updated version.

The reason why you should care about Yoast’s WordPress SEO sitemap 404 error is because their sitemap helps your website to get indexed faster than natural XML sitemap or sitemaps generated by other third-party plugins.

Yoast SEO

download

How To Fix Yoast’s WordPress SEO Sitemap 404 Error?

The first thing you should do to fix Yoast’s WordPress SEO sitemap 404 error is to update the plugin itself. Sometimes, the older version retains the error, and the newer version corrects it. Similarly, you should take an update of your theme to solve the problem because it is very likely that the problem is due to your theme than your plugin. It might just work, else try the following.

Method 1 – Tweaking The Plugin

You need to try out the easiest things first. Go to Yoast SEO plugin’s settings and Disable XML sitemap. Clear the cache of your website and log out of the site. Log in back and Enable XML sitemap again. It might just fix Yoast’s WordPress SEO sitemap 404 error.

The second easiest thing you need to try is to deactivate the plugin and reactivating it by clearing the cache and log in back again. You can also try to uninstall the plugin and install it back with the latest version. But make sure you know the settings that you did when you installed it the first time so that your website does not get affected by any means.

Method 2 – Tweaking The External Factors

Some users have reported that resetting their permalink has solved the problem. To reset the permalink, go to Admin Dashboard, then to Settings and finally to Permalinks. Do not make any changes and just click on Save Changes button.
There are various reports that say your theme along with W3 Total Cache is responsible for the glitch. W3 Total Cache plugin is something most people install, and some themes have it pre-installed for faster page loading speed.

Generally, the sitemap provided by Yoast SEO plugin stops working after you install W3 Total Cache.

If that is what happened with you as well, you need to go to Admin Dashboard and then to Performance menu option. Under performance, you will find Browser Cache option on which you need to click.

In the textbox beside Prevent caching exception list label,

add sitemap(_index|[0-9]+)?\.xml

In the textbox beside 404 error exception list label, add the following at the end of the lines already present.

sitemap(_index)?\.xml(\.gz)? 
[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?

Save the changes and see whether it is able to fix Yoast’s WordPress SEO sitemap 404 error.

Method 3 – Solving the problem with .htaccess file.

If none of the above works for you, you have to go for the most reliable solution. First, you need to have FTP software installed like FileZilla. You need to open the software and connect it to your web server. On the main directory, find the important file .htaccess. Take a backup of the file by downloading it and storing it safely as we are about to add codes to that which if you mess up could crash the site.

Now, open .htaccess file and add the following code at the end of the file.

# 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

This should solve the problem, but some people have also reported that it did not work for them as Google Webmaster Tool was unable to find the XML sitemap file.

Method 4 – The Ultimate Solution

This is not a recommended step as it involves editing the core files of the plugins and it might just make the plugin vulnerable. But if you are determined and have enough confidence, you can connect your FTP to your web server and go to wp-content folder. Find plugins and inside it, you will find wordpress-seo folder which represents Yoast SEO plugin. Go inside it and enter the folder INC. Inside that, you will find class-sitemaps.php which is the culprit. Open the file and search for the function init().

Remove whatever is written inside the function and paste the following code.

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' );
        $wp_rewrite->flush_rules();
    }

Save the file and go back to Admin Dashboard. Then go to Yoast plugin settings and disable sitemap. Clear the cache of the browser and log in back. Enable the sitemap option again and your problem is sure to be solved.

If none of the above works for you, you can go for the premium version of Yoast SEO and contact their support team if you face any problem. But with the premium version, you are not going to face the problem. Why the problem is appearing and why Yoast is not doing anything about it is questionable. But it is a fact that you have to stick to Yoast SEO plugin and fix Yoast’s WordPress SEO sitemap 404 error for better ranking and faster crawling by search engine crawlers.

Thank you for visiting SKT Themes a place for selecting top WordPress Themes from a list of several hundred templates. Happy Reading and Shopping.