Sitemap 404 and 500 Internal Server Error after adding Rank Math

#1122578
  • Hello Rank Math team,

    I’m experiencing an issue with the sitemap on my WordPress website:
    https://lingoculture.kr

    After reinstalling Rank Math, the sitemap URL (https://lingoculture.kr/sitemap_index.xml) returns a 404 error.
    I followed your official documentation here:
    https://rankmath.com/kb/sitemap-404-error/

    As instructed, I added the following rewrite rules to my .htaccess file (above the Breeze cache section):

    # START of Rank Math Sitemap Rewrite Rules
    RewriteEngine On
    RewriteBase /
    RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 L
    RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 L
    RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 L
    # END of Rank Math Sitemap Rewrite Rules

    However, immediately after saving the file, my entire website went down with a **500 Internal Server Error**.

    I contacted my hosting provider (Cloudways), and they confirmed that this .htaccess code caused a server-level misconfiguration.
    They restored my site by removing the Rank Math rewrite rules.

    After recovery, my site works fine again, but the sitemap (https://lingoculture.kr/sitemap_index.xml) still returns a 404 error.
    Meanwhile, the default WordPress sitemap (https://lingoculture.kr/wp-sitemap.xml) works normally.

    Here’s what I have already tried:
    1. Cleared all cache from Breeze plugin and Cloudways Varnish.
    2. Disabled and re-enabled the Sitemap module in Rank Math.
    3. Resaved permalinks in WordPress.
    4. Excluded sitemap URLs from caching as suggested in your documentation.
    5. Reinstalled Rank Math completely.

    Despite all of these steps, Rank Math’s sitemap still shows 404, and adding the rewrite rules again results in a 500 Internal Server Error.

    **Update:**
    After the Internal Server Error occurred, my hosting provider (Cloudways) investigated the issue.
    They confirmed that the rewrite rules from your documentation caused the Apache configuration to fail.

    Here’s what they said:
    > “The code provided by Rank Math is causing an error, which means there is an issue in the code itself.”

    They also shared the exact server log showing the error:

    This confirms that the .htaccess rewrite rule example from your guide:
    https://rankmath.com/kb/sitemap-404-error/
    does not work properly on Cloudways (Apache 2.4 / Debian).

    Could you please verify and provide a corrected version of the rewrite rule that is compatible with Apache 2.4 / Cloudways environments?

    Thank you for your help and time!

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

    We apologize for the issues you are facing with the sitemap on your website. It sounds like you’ve taken several steps to troubleshoot the 404 error, and we appreciate your detailed description of the situation.

    Since you are encountering a 404 error for the Rank Math sitemap after adding the rewrite rules, here are a few additional steps you can try:

    1. Flush the Sitemap Cache: After adding the rewrite rules, ensure you flush the sitemap cache. You can do this by navigating to Rank Math SEO → Sitemap Settings and changing the Links Per Sitemap setting. After that, click on Save Changes. Then, go to Settings → Permalinks in your WordPress admin area and hit Save Changes again, even if you didn’t make any changes. This will help refresh the permalinks and may resolve the issue.
      Links Per Sitemap
      Permalink Settings in WordPress
      Save Changes

    2. Check for Server Configuration: Since your hosting provider mentioned that the rewrite rules caused a misconfiguration, it might be worth checking if there are any specific server settings or restrictions that could be affecting the functionality of Rank Math. If you’re using an Nginx server, ensure that the correct rewrite rules are added to your Nginx configuration as well.

    3. Disable Caching Plugins Temporarily: While you’ve already excluded the sitemap from caching, it might help to temporarily disable any caching plugins (like Breeze) to see if that resolves the issue.

    4. Ensure Pages Are Set to Index: Make sure that your posts and pages are set to index in the robots meta tag. If any pages are set to noindex, they will not appear in the sitemap, which could lead to a 404 error.
      set to noindex
      You can check this by navigating to Rank Math SEO → Advanced tab in the post editing screen.

    If these steps do not resolve the issue, we recommend replying to this ticket with your site URL and any additional details about your server setup. A human agent from our support team will be able to assist you further and provide more tailored guidance.

    Thank you for your patience, and we hope to resolve this issue for you soon!

    Sources:
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.

    Hello Rank Math Team,

    Thank you for your previous response.
    I have carefully followed all the steps suggested in your guide, including:

    Flushing the sitemap cache by changing the “Links Per Sitemap” setting and saving changes.

    Refreshing permalinks under Settings → Permalinks.

    Temporarily disabling the Breeze caching plugin.

    Verifying that all pages are set to “index” in the Rank Math settings.

    However, the sitemap issue still persists — the sitemap cannot be found at
    👉 https://lingoculture.kr/sitemap_index.xml

    My hosting provider (Cloudways) has reviewed the issue and asked me to share the following points with your team:

    The sitemap appears to have been generated but still shows “not found.”

    The .htaccess code provided by Rank Math caused an internal server error (500), which indicates there might be a syntax or compatibility issue with that rewrite rule.

    The sitemap URL (sitemap_index.xml) has already been excluded from all caching, so caching is not causing this problem.

    Could you please review this and confirm whether there’s an updated or corrected rewrite rule that should be used for Cloudways (Apache + Nginx hybrid) servers?

    Thank you so much for your help. I look forward to your further guidance.

    Best regards,

    Hello,

    If your server is Nginx, then this is the code you should add to your config file:

    # 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

    You can get in touch with your web host for assistance if you’re unser about the process.

    If the issue persists, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.

    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hi Reinelle,

    Here is the temporary login link to check the sitemap issue:
    [Moved to the sensitive data section]

    This link will automatically expire in 3 days.

    Thank you!

    Hello,

    We have checked your website and noticed that you currently have only one post, which is still in draft.

    Please note that Rank Math includes only published posts and pages in the sitemap, and they must be set to index with a self-referencing canonical URL. Since there is nothing to add to the sitemap at the moment, it is returning a 404 error.

    Once you publish posts and pages on your website, the sitemap will start working automatically.

    We hope this clarifies the situation. Please feel free to reach out if you have any further questions.

    Thank you.

    James Miller
    Rank Math free

    Short, exact, and solution-focused:

    The 500 was caused by bad/unsafe rewrite syntax for your server. Try these Apache-safe rules (escape dots, no leading slash, proper flags):

    Backup your .htaccess.

    Add above other rules:

    # Rank Math sitemap fixes (Apache 2.4 / Cloudways)
    RewriteEngine On
    RewriteBase /

    RewriteRule ^sitemap_index\.xml$ index.php?sitemap=1 [L,QSA]
    RewriteRule ^([^/]+?)-sitemap([0-9]+)?\.xml$ index.php?sitemap=$1&sitemap_n=$2 [L,QSA]
    RewriteRule ^([a-z]+)?-?sitemap\.xsl$ index.php?xsl=$1 [L,QSA]

    Save, then: WordPress → Settings → Permalinks → Save (flush rewrites).

    Clear Breeze, Varnish, and browser cache.

    If you still get a 500:
    • Revert .htaccess and ask Cloudways to check Apache error logs — include the exact .htaccess snippet and the timestamp of the failure.
    • If Cloudways uses Nginx in front, they may need equivalent Nginx rules in the application config instead of .htaccess. Ask support to add the rules or confirm AllowOverride and mod_rewrite are enabled for your vhost.

    If you want, I can format the equivalent Nginx rules you can paste to Cloudways support.

    Hello @james-miller-1093,

    Thank you so much for your contribution. Yes, the 500 error code is usually caused by incorrect server configuration, and your suggestion is very helpful for other users who might be experiencing such issues.


    @bravomylady
    ,

    We can see that your sitemap is now working.

    Let us know if you still need our assistance with your issue.

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

You must be logged in to reply to this ticket.