• Resolved haywardgb

    (@haywardgb)


    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.*(?:\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;

    When I use this block in my Nginx config. Nginx restarts and then fails with the following error:

    nginx: [emerg] directive "rewrite" is not terminated by ";"
    • This topic was modified 6 months, 3 weeks ago by haywardgb.
    • This topic was modified 6 months, 3 weeks ago by haywardgb.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter haywardgb

    (@haywardgb)

    Apparently it’s the {1,4}

    Replacing all instances of {1,4} with +, fixed it.

    • This reply was modified 6 months, 3 weeks ago by haywardgb.
    humblearab

    (@humblearab)

    Just came across this after copying the rewrite rules from the plugin.

    If replacing {1,4} with + fixes the problem, it suggests that the {1,4} quantifier might be interpreted incorrectly by Nginx. To use {1,4} correctly, you should escape the curly braces with backslashes:

    However, using + as a replacement for {1,4} works if you only need to match one or more digits instead of a specific range. The + quantifier matches one or more of the preceding elements, which simplifies the regular expression.

    Regex headache again ??

    The correct rules, that would work by default would be

    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.*(?:\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;

    I think the {1,4} is meant to capture part of the sitemap where it might be something like product-sitemap1234.xml

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.