• Resolved MikeX3

    (@mikex3)


    I have discovered that WP Cloudflare Super Page Cache nginx rules are breaking my SEOPress sitemap. Please read on for details…

    I’m currently using SEOPress on nginx, with the following rewrite rules in a conf file:

    location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
    ## SEOPress
    rewrite ^/sitemaps.xml$ /index.php?seopress_sitemap=1 last;
    rewrite ^/sitemaps/news.xml$ /index.php?seopress_news=$1 last;
    rewrite ^/sitemaps/video.xml$ /index.php?seopress_video=$1 last;
    rewrite ^/sitemaps/author.xml$ /index.php?seopress_author=$1 last;
    rewrite ^/sitemaps_xsl.xsl$ /index.php?seopress_sitemap_xsl=1 last;
    rewrite ^/sitemaps/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?seopress_cpt=$1&se$

    As soon as I add the WP Cloudflare Super Page Cache nginx rules, my sitemaps.xml file throws a 404 error. Turning off the rules immediately fixes the issue. The rules I’m referring to are:

    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/mydomain.com/debug.log { access_log off; deny all; }

    I’m no expert with nginx so I’m not sure what about this rule is breaking the SEOPress rewrite rules. Maybe it’s an easy fix, maybe not, but I’m hoping someone here might have the answer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    first of all, try to put the seopress rules below the wp cloudflare rules. If it still breaks the remove the location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; } line from your nginx.config and see.

    The location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; } is not going to work for you anyways. But I don’t see how that rule can break your sitemaps. But You can try removing that rule.

    The reason that rule is not going to work for you is because the rule is being set on physical XML and xsl files but in case of the seopress if you look at the nginx rules, there is actually no physical XML or xsl files for the sitemaps. Instead when you visit any of the sitemap URLs, it is basically executing a PHP file to generate the content of that page and giving the system an illution that the actual file is XML.

    This is a common practise a lot of SEO plugin does, but again the nginx rule added by this plugin should not break the sitemap as it is working flawless with many SEO plugin like rankmath which does the similar thing.

    Anyways try removing the location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; } line from your nginx.conf file and then restart NGINX and see what happens.

    Thread Starter MikeX3

    (@mikex3)

    Thank you. I just decided to go with this for now (commenting out the first line):

    #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/mydomain.com/debug.log { access_log off; deny all; }

    At least this way the rest of the rules are there. I purge all the cloudflare cache anyway after publishing a new blog post, so if the sitemap does get cached it’s no big deal. Thanks for your assistance.

    • This reply was modified 3 years, 4 months ago by MikeX3.
    Plugin Contributor iSaumya

    (@isaumya)

    Thanks for confirming.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘SEOPress sitemaps.xml 404 issue’ is closed to new replies.