Nginx rewrite rules for Yoast SEO

I found your rules here: https://rtcamp.com/wordpress-nginx/tutorials/plugins/yoast-seo-sitemap/ and they are slightly different from what I was using but I don't know enough to understand what's "better" or safer.

Care to let me know which set I should use, yours or mine?

mine:

location ~ ([^/]*)sitemap(.*)\.xml$ {  
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;  
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;  
}  

We tested and used https://rtcamp.com/wordpress-nginx/tutorials/plugins/yoast-seo-sitemap/ on rtcamp.com site and its recommanded to use that rules.

Also if your rules works fine then you can used your own rules

Thanks - as I said, I can’t fully understand these rewrites so I am unsure if there is anything wrong with mine or yours but they differ slightly…

Hi,
I am having problems with yoast rewrite rules.
I added the rules mentioned in this article. https://rtcamp.com/wordpress-nginx/tutorials/plugins/yoast-seo-sitemap/

under sudo nano /etc/nginx/sites-available/default
.

When I open sitemap I get 404 error.
I use digital ocean vps and I initially installed wordpress using ip so inside server block I have server_name Ip_address;

Do I need to change Ip address to my site name. and will it cause problems to current config?
Please help.

It doesn’T really matter how you installed WP, what matters is that the rules go into the same nginx vhost config that powers your WP site.

What is the link to your site and can you paste your nginx config to say pastebin.com and share the link?

Looking closer at your post, is the default nginx vhost powering your site?