Yes, I myself manage my server setup with nginx. I tried all the steps listed below but the problem still exists.
1. Clearing WP-Rocket (Cache Plugin), Cloudflare, FastCGI Cache.
2. Database Cleanup, Removing Rankmath and other Transients.
3. Switching to an older version of rank math. (Just up to 1.0.69) and disabling all plugins.
4. Plugins like Yoast SEO working fine with the sitemap. (Already removed plugin and data from the database after seeing the problem is with RankMath only).
Let me tell you as I said above I have four WordPress sites hosted on one nginx server and out of these two are working fine but the remaining two have problems with the post-sitemap.xml and page-sitemap.xml
Problem ———
1. examle.com/sitemap_index.xml (works fine) but
2. example.com/post-sitemap.xml or example.com/page-sitemap.xml is throwing 302 error and keeps redirecting and not loads.
The solution worked for me ———
# 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
(Replacing $ variable with / ) in two sites which does not load post-sitemap.xml
I have updated the sensitive data with another site that currently has a problem and I have not replaced the $ variable with / in the rank math sitemap rewrite rule.
Here is the header output for the same. I replaced site with example.com, consider site 2 (i.e last two-line added in sensitive data).
Request URL: https://example.com/post-sitemap.xml
Request Method: GET
Status Code: 302
Remote Address: 104.21.47.186:443
Referrer Policy: same-origin
alt-svc: h3-27=”:443″; ma=86400, h3-28=”:443″; ma=86400, h3-29=”:443″; ma=86400, h3=”:443″; ma=86400
cf-cache-status: DYNAMIC
cf-ray: 67c294c13ec01da5-BLR
content-security-policy: default-src ‘self’ https: data: ‘unsafe-inline’ ‘unsafe-eval’;
content-type: text/html; charset=UTF-8
date: Mon, 09 Aug 2021 17:07:30 GMT
expect-ct: max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”
fastcgi-cache: BYPASS
location: https://example.com/post-sitemap.xml
nel: {“success_fraction”:0,”report_to”:”cf-nel”,”max_age”:604800}
permissions-policy: geolocation=();notifications=(self);push=(self);payment=();camera=();microphone=();speaker=(self);fullscreen=(self);
referrer-policy: same-origin
report-to: {“endpoints”:[{“url”:”https:\/\/a.nel.cloudflare.com\/report\/v3?s=U5TpHwq0ludZyP8j6SJN%2BBu52P0gIsnhJ4Y1gmUkYBnEJvUjHsJw6MrjBtVEqeXqunCfproe03%2BGGGO23z8hSnEnDNi6EfQ0PRCmZkXo6HIdDwNCoNOW5PcSPTqD1ZSD”}],”group”:”cf-nel”,”max_age”:604800}
server: cloudflare
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-redirect-by: WordPress ( I don’t know why this is showing)
x-xss-protection: 1; mode=block
:authority: example.com
:method: GET
:path: /post-sitemap.xml
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-IN,en;q=0.9
cache-control: max-age=0
referer: https://example.com/sitemap_index.xml/
sec-ch-ua: “Chromium”;v=”92″, ” Not A;Brand”;v=”99″, “Google Chrome”;v=”92″
sec-ch-ua-mobile: ?0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36