NGINX server, you may need to add the following code to your configuration file

#1073466
  • Resolved Cyberdome
    Rank Math free

    Since you are using an NGINX server, you may need to add the following code to your configuration file if your Sitemap pages are not loading. If you are unsure how to do it, please contact your hosting provider.
    Hide
    I already added

    # 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

    Please provide detailed information on how to fix this error in the sitemap as we don’t know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    I apologize for the issue you are facing with your sitemap on the NGINX server. Since you’ve already added the rewrite rules to your configuration file, let’s go through some additional steps to troubleshoot and fix the sitemap issue.

    1. Verify Sitemap Generation

    First, check if your sitemap is being generated correctly. You can do this by visiting:

    `https://premium.wpmudev.org/blog/w3-total-cache-settings/#uaGroups?utm_campaign=RankMath

    If this URL loads your sitemap, it means that Rank Math is generating it successfully but may not be able to rewrite it to sitemap_index.xml.

    2. Add Additional Rewrite Rules

    If the sitemap is not loading, ensure that you have included all necessary rewrite rules in your NGINX configuration file. Here’s the complete set of rules you should have:

    # 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;
    rewrite ^/([a-z]+)?-sitemap.xsl$ /index.php?xsl=$1 last;
    # END Nginx Rewrites for Rank Math Sitemaps

    3. Flush Sitemap Settings

    After adding or modifying the rewrite rules, you need to flush your sitemap settings:

    • Go to Rank Math SEO → Sitemap Settings in your WordPress admin area.
    • Make a minor change to the Links Per Sitemap count and click Save Changes.

    Flush Sitemap Settings

    4. Flush Permalinks

    Next, navigate to WordPress Dashboard → Settings → Permalinks. You don’t need to make any changes here; just click the Save Changes button to flush the permalinks.

    Flush Permalinks Settings

    5. Exclude Sitemap from Caching

    Ensure that your sitemap is excluded from caching. If you are using a caching plugin, refer to this dedicated knowledgebase article for guidance.

    6. Disable Transient Caching (if necessary)

    If the above solutions do not resolve the issue, you can disable transient caching by adding the following filter to your theme’s rank-math.php file:

    /**
     * Filter if XML sitemap transient cache is enabled.
     *
     * @param boolean $unsigned Enable cache or not, defaults to true
     */
    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    7. Check for Conflicts

    If you are still experiencing issues, check for potential plugin conflicts using the Health Check plugin.

    If you continue to face problems after trying these steps, please reply to this ticket with your site URL so that a human agent can assist you further. Thank you for raising this concern!

    Sources:
    Rank Math XML Sitemaps on NGINX Servers » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Hello,

    The notice is only there since you’re using Nginx.

    If your sitemap is loading fine, then you won’t need to add the code in the notice.

    Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘NGINX server, you may need to add the following code to your configuration file’ is closed to new replies.