-
Hi everyone.
First of all i found what the problem is and fixed it but i don’t know how this cause 404 not found problem. I will share this with you.I have a LEMP Debian Nginx server and wordpress site in it.
I did not add this below code to my nginx i don’t use it, despite this sitemap works on my nginx without any problem.
# 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 SitemapsBut what is the problem?
I use cloudflare and Wp cloudflare super cache.
I activated browser cache from this plugin as well so plugin warned me to add this below block to my nginx.location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"; expires 30d; }
location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"; expires 365d; }
location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
location = /wp-content/wp-cloudflare-super-page-cache/wifisifrekirici.com/debug.log { access_log off; deny all; }Although if we don’t add this codes, wp cloudflare cache plugin doesn’t cache the sitemap and robots.txt. But this block has a line about xml/xsl and all block is actually for static pages.
What is the conflict?
At above code there is a line!
location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
If i add this line with above code block to nginx, sitemap gives 404 not found error when click sitemap url!
If i remove this line from above block and add rest of codes sitemap works excellent without any error!I made some tests! I removed this line and checked the sitemap page from chome network editor.
cloudfare bypassed the page without caching and there is a line!
cache-control: no-cache, no-store, must-revalidate, max-age=0 Because without adding any code i told you Wp cloudflare super cache always doesn’t cache sitemap!I have 2 questions!
1) But i dont’t know why my site gives 404 error on sitemap link when i add this line to nginx?
location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
2) How my sitemap works without adding below code, despite i have nginx server 🙂
# 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 SitemapsThanks very much.
In this topic i shared the conflict between Wp cloudflare super cache and Rankmath on a nginx server!
The ticket ‘Nginx sitemap 404 not found [Bug Solved – Conflict With WP Cloudflare Cache]’ is closed to new replies.