How to fix XML Sitemap 404 Not Found error in Yoast plugin?

After successfully installing WordPress, you will need to install some plugins, such as Yoast SEO.

Do you use Yoast’s plug-in Wordpess SEO (also known as Yoast SEO or Wordpess SEO) to optimize Wordpess SEO and use it to create a sitemap for your website/blog?

And when submitting the sitemap to the Google Search Console, a 404 Not Found error message will appear. And you try to check your sitemap under the path or, it returns a 404 Not Found error (error not found).

So is this an error caused by a Yoast SEO plugin or hosting/server error or you misconfigured Yoast SEO?

Let us find out the reasons and how to fix the 404 error when using WordPress SEO to create a sitemap in the following content.

Fix XML Sitemap error 404 Yoast Seo

Fix 404 error for sitemap created by Yoast SEO

First of all, We would like to confirm that the 404 error of this sitemap is not caused by the Yoast SEO plugin. If you have time can read the answer page in English, this is also confirmed by the author of the plugin. So what is the cause of the error?

Before finding out why you must ensure that the sitemap creation feature in the Wordpess SEO plugin is enabled. If it is not enabled, 404 errors are natural. If you have opened it but still have errors, please continue reading below

1. Error due to static path structure (Permalinks) changes.

You won’t know if it’s the static path or not, but you can try the following. If it can be fixed, it’s because the path is static, if not, it’s okay.

You access the Admin page -> Settings  -> Permalinks then click Save without having to change anything.

Save permalinks

2. Sitemap has no data

Log in to the WordPress Website, select Edit Post or Page.

Expand the Advanced section and select ‘Allow search engines to show this Post in search results?’ to “Yes” for the Post or Page being edited.

Allow search engines to show

3. Error because rewrite has not been set up on Webserver

If your 404 error still exists, you can check the configuration file of the webserver to see if a rewrite is added. If a rewrite is not added, please follow the steps below to use Apache and Nginx web servers.


If you use Apache, just add the following code to the .htaccess file and save it.

Note: back up the .htaccess file in case something goes wrong.

# Yoast 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?yoast-sitemap-xsl=$1 [L]
# END Yoast SEO - XML Sitemap Rewrite Fix


If you are using Nginx and the sitemap has a 404 error, then open the domain configuration file in Nginx at the path /home/ and add the following code:

rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
rewrite ^/sitemap.xml$ /sitemap_index.xml permanent;
rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?yoast-sitemap-xsl=$1 last;
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
rewrite ^/news-sitemap.xml$ /index.php?sitemap=wpseo_news last;
rewrite ^/locations.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo-sitemap.xml$ /index.php?sitemap=wpseo_local last;
rewrite ^/video-sitemap.xsl$ /index.php?yoast-sitemap-xsl=video last;

Hope the above description can help you solve the error you are facing. Use the comment box below to tell us what you think about this article🙂

You May Also Like
About the Author: Anh
Blogger at

Leave a Reply

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