How to Fix Yoasts WordPress SEO Sitemap 404 Error

If you are working with the older version of the SEO site map plugin for a long time, then it can create a problem. However, to fix Yoast’s WordPress SEO Sitemap 404 error, updating the plugin can help.

If it’s still not set, then you can use the following methods:

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.

Yoasts WordPress SEO Sitemap 404 Error

Yoast SEO

Yoast SEO

download

yoast seo

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.

SEO Sitemap

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.

WordPress SEO sitemap

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.

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.

htaccess file

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.

Yoast plugin settings

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.

Method 5: Exclude the particular sitemap content:

You can check the existing items to create each sitemap. For a category sitemap, it is essential to have then categories with the published contents.

In case the things are not existing, stat with excluding the post type. You can also exclude the taxonomy from the site map before creating any other content.

To do this, log in with your WordPress site and go to the dashboard. Then you need to edit the post on the page from the menu visible on the left side. From that menu, you need to navigate towards the post that you want to exclude.

Then it would be best if you expanded the ” advanced” section to change the ‘ allow the search engine to show this post in search result?’ towards the ‘ No’ for this particular post on the page. Now you need to publish or update the post.

Method 6: Rewrite the missing rules:

If still there are the signs for receiving the 404, now you need to check for the rewrite rules on the server. Also, you can try rewriting the rules on your server to fix the problem regarding the 404 errors on your Yoast SEO site.

To rewrite the rules for your server, you can check the Apache server or the NGIN server. However, in case you are not sure about how to check the rules of the server you are using, or you are not sure about how to enter them, you can contact your host service provider to fix Yoast’s WordPress SEO Sitemap 404 error.

Method 7: Update the structure of the permalink:

External factors like the permalink can also cause the 404 error in your Yoast SEO. However, you can fix it by resetting the permalink.

Go to the Admin Dashboard to rest the permalink. Then you need to go to Settings and then go to the permalink. Now without making any changes, click on the Save Changes button.

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.

About Sonnal S Sinha

Sonnal S SinhaSonnal S Sinha is a passionate writer as well as WordPress and WooCommerce rockstar who loves to share insights on various topics through his engaging blog posts. He run successful website design and digital marketing company. With 15+ years of experience in WordPress themes development, he strives to inform and inspire readers with his thought-provoking content. He helps thousands small and medium businesses and startups create a unique online presence. Follow Sonnal S Sinha for your regular dose of knowledge and inspiration.