If you are facing 404 error in nginx when accessing Yoast SEO sitemap in your wordpress blog eg: https://example.com/sitemap_index.xml

Then Add below lines to the top of your sites-enabled config file (inside server block), Otherwise, these rule may conflict with other rules in  your sites-enabled config

# Rewrites for Yoast SEO XML Sitemap
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

Check for any syntax errors in nginx config
nginx -t

Reload Nginx Server
service nginx reload

To see your sitemap file visit: https://example.com/sitemap_index.xml

Fix – 404 Not Found error in nginx when accessing yoast seo sitemap
Tagged on:     

Leave a Reply

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

%d bloggers like this: