Yoast XML Sitemaps on NGINX subfolder

If you have your WordPress site in a subfolder the official documentation won't help you unless you know a little bit of NGINX.

Here's the snippet to make Yoast SEO plugin XML feature work with a WordPress install inside a subfolder, in the example below would be inside a /blog/ subfolder.

server { # ... other configs ... # Rewrites for Yoast SEO XML Sitemap rewrite ^/blog/sitemap_index\.xml$ /blog/index.php?sitemap=1 last; rewrite ^/blog/([^/]+?)-sitemap([0-9]+)?\.xml$ /blog/index.php?sitemap=$1&sitemap_n=$2 last; }
Code language: PHP (php)

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.

*
*