Yoast sitemap_index.xml 404 not found error


Yoast sitemap_index.xml 404 not found error : This Error occurs basically when you have not added rewrite rules to the .htccess file which exists at the root of your wordpress site. You can fix this issue quickly by adding the rewrite rules.


Fix for Yoast sitemap 404 not found error

Add the following rules in .htaccess file –

For Apache

If you are using apache add the following lines in .htaccess file.

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

For NGINX

If you are using NGNIX add the following lines in NGNIX config.

#Yoast sitemap
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
        ## this redirects sitemap.xml to /sitemap_index.xml
	rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
        ## this makes the XML sitemaps work
        rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?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;
        ## The following lines are optional for the premium extensions
	## News SEO
        rewrite ^/news-sitemap\.xml$ /index.php?sitemap=wpseo_news last;
	## Local SEO
	rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
	rewrite ^/geo-sitemap\.xml$ /index.php?sitemap=wpseo_local last;
	## Video SEO
	rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;
}

Advertisements

Add Comment