Nginx sitemap and rank math -

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

rank math white screen sitemap developer tools 1 -

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.

Written by

We are a small group of proven, result oriented, experienced web development professionals competent to international standards. We have reciprocal professional backgrounds and expertise in management, programming, design & creative skills. We can assure you elegant, creative digital solutions for your business needs which are superior in design, coding and standards which represent your brand/business pixel perfectly in the online world.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Top
infuse logo

CONTACT ADDRESS
Aspin Commercial Tower, Sheikh Zayed Road, Dubai-UAE

GENERAL INQUIRIES
hello@infuse.ae

PROJECT INQUIRIES
projects@infuse.ae

PHONE NUMBER
+971 50 6788 626

SOCIAL MEDIA

Our Support Contact Number has Changed!
NEW NUMBER