Yoast WordPress SEO XML Sitemap Problem on Nginx

If you are using WordPress SEO plugin from Yoast to generate XML sitemaps on your WordPress site running on Nginx, the sitemap could be loaded without any style information. This is due to a missing rewrite rule.

If your site is running on Nginx and if you turn on XML sitemaps from the WordPress SEO plugin, it will provide you with two Nginx rewrite rules.

wordpress seo yoast nginx rewrite rules

Once the two rewrite rules have been added to Nginx and if you try to load the XML sitemaps from a browser, the sitemap will get loaded, but with errors. On Firefox, it got rendered as plain text. On Chrome, the page was blank. And if you tried to monitor the HTTP requests and responses using developer tools, you will notice a 404 error while retrieving the main-sitemap.xsl file. The main-sitemap.xsl file is the XML stylesheet that contains the presentation information. Without this file, the browser will not know how to display the XML sitemap properly.

The workaround for this problem is to add an additional rewrite rule to Nginx. Append the following rewrite rule immediately after the default Nginx rewrite rules provided by the WordPress SEO plugin.

Once the rule is in effect, the browser will load the XML sitemaps correctly.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }