![Fix/Troubleshoot Rank Math Sitemap with Nginx Successfully 1 Nginx sitemap and rank math -](https://www.infuse.ae/wp-content/uploads/2022/03/Nginx-sitemap-and-rank-math.webp)
Fix/Troubleshoot Rank Math Sitemap with Nginx Successfully
I recently had some issues when configuring Rank Math Sitemaps feature in the Infuse website which runs on a VPS with Ubuntu 20.0.4 and Nginx.
Basically the issue I faced was that the sitemap was generating a blank/white page
So, I started scouring the internet looking for a fix for the same and found this on the rank math website. I also noticed a lot of people having this issue as I searched for “rank math sitemap not working”, “rank math sitemap 404”, “rank math > sitemap cache”, “rankmath custom sitemap” and “update sitemap rank math”. I also found a very informative link on the Rank Math website.
Rank Math Sitemap Issues and Their Fixes
As per the article, the Rank Math website asks you to add the following lines to the Nginx configuration.
# 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
I went ahead added this to infuse’s Nginx configuration which is basically at
/etc/nginx/sites-available/infuse.ae.conf
Add it as the last part of the server {…..} block
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
..............................................
..............................................
..............................................
# 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
}
Reload the new configuration on nginx using the command
nginx -t
systemctl reload nginx
Now, I went back and tried https://www.infuse.ae/sitemap_index.xml and was returned with the white screen still.
To troubleshoot this, on chrome, I tried ctrl+u which showed the page source. I noticed, the source has the xml data in place which led me to understand that the sitemap styling is not working. Clicking F12 loaded DevTools which showed that main.sitemap.xsl file is not loading
![Fix/Troubleshoot Rank Math Sitemap with Nginx Successfully 2 rank math white screen sitemap developer tools 1 -](https://www.infuse.ae/wp-content/uploads/2022/03/rank-math-white-screen-sitemap-developer-tools-1-1024x505.png)
I went back to the nginx configuration and modified the the config to below so that URL Rewrite works for the xsl file as well
# START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/main-sitemap.xsl$ /index.php?xsl=$1;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# END Nginx Rewrites for Rank Math Sitemaps
reload the new nginx configuation
nginx -t
systemctl reload nginx
Went ahead, refreshed https://www.infuse.ae/sitemap_index.xml
Voila! Rank Math Sitemaps are now visible.
The issue with Rank Math Sitemap is solved.
Thank you very much for your help!