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

shyam jos

My name is Shyam Jos, I am a passionate Linux system administrator from Kochi, India. I am a strong advocate of using Linux and Open-Source software.

1 Comment

Maruf Alom · September 19, 2019 at 9:38 PM

Doesn’t fix for me

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.