From fba9729581782ec20d3a6feaecb67fbdca181965 Mon Sep 17 00:00:00 2001 From: Chingis Sandanov Date: Mon, 6 May 2024 18:12:43 +0300 Subject: [PATCH] Update rules for WP google xml sitemap, closes #89 --- templates/presets/wordpress.conf.tmpl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/templates/presets/wordpress.conf.tmpl b/templates/presets/wordpress.conf.tmpl index 35c519d..f5c98fa 100644 --- a/templates/presets/wordpress.conf.tmpl +++ b/templates/presets/wordpress.conf.tmpl @@ -12,11 +12,22 @@ add_header X-Content-Type-Options nosniff; add_header Cache-Control "store, must-revalidate, post-check=0, pre-check=0"; {{- end }} +# https://plugins.trac.wordpress.org/browser/google-sitemap-generator/trunk/class-googlesitemapgeneratorloader.php#L172 {{- if getenv "NGINX_WP_GOOGLE_XML_SITEMAP" }} -rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last; -rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; -rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; -rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last; +rewrite ^/.*-misc?\.xml$ "/index.php?xml_sitemap=params=$2" last; +rewrite ^/.*-misc?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; +rewrite ^/.*-misc?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; +rewrite ^/.*-misc?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last; + +rewrite ^/.*sitemap.*(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last; +rewrite ^/.*sitemap.*(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; +rewrite ^/.*sitemap.*(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; +rewrite ^/.*sitemap.*(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last; + +rewrite ^/.*sitemap.*(?:\d{1,4}(?!-misc)|-misc)?\.xml$ "/index.php?xml_sitemap=params=$2" last; +rewrite ^/.*sitemap.*(?:\d{1,4}(?!-misc)|-misc)?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; +rewrite ^/.*sitemap.*(?:\d{1,4}(?!-misc)|-misc)?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; +rewrite ^/.*sitemap.*(?:\d{1,4}(?!-misc)|-misc)?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last; {{- end }} location = /robots.txt {