1. Home
  2. Knowledge Base
  3. SEO Suite
  4. Rank Math XML Sitemaps on NGINX Servers

Rank Math XML Sitemaps on NGINX Servers

Rank Math creates a virtual sitemap dynamically that relies on using redirects on the server-level. In certain situations where your sitemap appears not to be working as intended, you’ll need to add some rewrite rules manually.

To ensure that you need to add these rewrite rules, go to domain.com?sitemap=1.

Check Sitemap generation in Rank Math

If your sitemap loads, then it means Rank Math is able to successfully generate the sitemap of your website but, it is unable to rewrite the sitemap to sitemap_index.xml page.

Fix Sitemap Issues on Nginx Server

If your Nginx server is preventing the creation of the sitemap file, then Rank Math would also let you know through a notice under Sitemap Settings. In that case, you need to manually add the rewrite rules.

Rank Math Sitemap notice on Nginx server

1 Add Rewrite Rules to Nginx Server

So head over to your Nginx config file and add the following rewrite rules to fix this:

# START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# END Nginx Rewrites for Rank Math Sitemaps

2 Flush Sitemap Settings

Once you’ve added the above rewrite rules, you’ll need to flush your sitemap settings. To do so, head over to Rank Math > Sitemap Settings in your WordPress admin area and make any minor changes to the Links Per Sitemap count. Then click the Save Changes button.

Links Per Sitemap in Rank Math sitemap settings

Next, navigate to WordPress Dashboard > Settings > Permalinks. You don’t need to make any changes here. Just click the Save Changes button.

Flush Permalinks seittings

4 Exclude Sitemap from Caching

Once you’ve flushed your Sitemap Settings, ensure that you’ve excluded your sitemap from caching. If you haven’t already done so, you can refer to this dedicated knowledgebase article to help you with it.

And, that’s it! We hope that this article has helped you resolve any potential issues with using Rank Math’s XML Sitemap on servers running Nginx. However, if you are still facing problems or have any queries please feel free to contact our support team and we’d be happy to help you at any given time.

Was this article helpful?

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles