Sitemap returns 404 error – Not generating correctly

#1111804
  • Hello Rank Math Support Team,
    I need urgent assistance with a critical sitemap issue that is preventing Google from indexing my website.
    Website: https://vdigital.it
    Issue: Sitemap returns “X-Robots-Tag: noindex” header
    Problem:
    My sitemap (https://vdigital.it/sitemap_index.xml) is accessible and displays correctly in browsers, but it’s sending an HTTP header that blocks Google from indexing it:
    X-Robots-Tag: noindex
    This is causing Google Search Console to report “Could not fetch sitemap” errors.
    HTTP Headers (verified via https://www.webconfs.com/http-header-check.php):
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=UTF-8
    X-Robots-Tag: noindex
    What I’ve tried:

    Disabled and re-enabled sitemap in Rank Math settings
    Cleared Rank Math sitemap cache multiple times
    Regenerated WordPress permalinks
    Added .htaccess rules to remove the header (didn’t work – nginx overrides it)
    Temporarily disabled WP Rocket and all caching
    Verified with SiteGround hosting that no server-level configurations are adding this header
    Checked all Rank Math settings for any “noindex sitemap” options

    My setup:

    Rank Math SEO: 1.0.254
    WordPress: 6.8.2
    Server: nginx (SiteGround)
    Active plugins: WP Rocket, Security Optimizer, Elementor

    Question:
    Is Rank Math adding the “X-Robots-Tag: noindex” header to the sitemap? If yes, how can I disable this setting? I’ve checked all visible settings in Rank Math but cannot find where this is configured.
    SiteGround hosting support confirmed they are not adding this header at the server level and suggested it’s coming from WordPress/Rank Math.
    Please provide:

    Where in Rank Math this header is being set
    How to remove or disable this header for sitemaps
    Any code snippets or configuration changes needed

    This is preventing Google from crawling my sitemap entirely. I need this resolved urgently.
    Please respond via email.
    Thank you for your help.

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

    We apologize for the issue you are facing with your sitemap returning a X-Robots-Tag: noindex header. This can indeed prevent Google from indexing your site properly.

    Possible Causes and Solutions:

    1. Check Robots Meta Tag Settings: Ensure that your posts and pages are set to index in the robots meta tag. You can check this by navigating to Rank Math SEO → Advanced tab in the post editing screen. If any of your pages are set to noindex, they will not appear in the sitemap.
      index in advanced tab

    2. Exclude Sitemap from Caching: Sometimes, caching plugins can interfere with the sitemap. Since you mentioned using WP Rocket, ensure that your sitemap is excluded from caching. You can refer to our tutorial on how to exclude sitemaps from caching here.

    3. Custom Code: If you have added any custom code to your theme or functions.php file that might be affecting the headers, please review that as well.

    4. Flush Permalinks: You mentioned you have already regenerated permalinks, but it’s worth doing it again just to be sure. Go to WordPress Dashboard → Settings → Permalinks and click Save Changes without making any changes.
      Flush Permalinks Settings

    5. Check for Plugin Conflicts: Since you have multiple plugins active, there could be a conflict. You can try temporarily deactivating all plugins except Rank Math to see if the issue persists.

    Additional Steps:

    If the above steps do not resolve the issue, you may want to consider adding the following code snippet to your theme’s functions.php file to ensure that the sitemap is not being set to noindex:

    add_filter( 'rank_math/sitemap/enable_caching', '__return_false' );

    This will disable caching for the sitemap specifically.

    Professional Setup Service:

    If you would like comprehensive assistance, we recommend our professional setup service, which ensures that your Rank Math plugin is configured correctly according to the latest SEO standards. You can find more information about this service here.

    If you continue to experience issues, please reply to this ticket with any additional details or changes you’ve made, and a human agent from our support team will assist you further.

    Thank you for raising this concern, and we hope to help you resolve it soon!

    Sources:
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    How to Fix "Incorrect HTTP Header Content-Type" Error in Sitemaps » 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,

    Please note that the sitemaps are by default set to Noindex as they are meant to be crawled and not to be displayed on search results pages. Even though it is set to Noindex, Google can crawl and read this without any issues.

    You should only submit your sitemap to the sitemap section of your GSC account and shouldn’t use the URL inspection tool for the sitemap URLs.
    https://rankmath.com/kb/submit-sitemap-to-google/

    In case you still want to index your sitemap, you can use the following filter on your website:

    add_filter( 'rank_math/sitemap/http_headers', function( $headers ) {
        $request_uri = $_SERVER['REQUEST_URI'];
    
        // Match all sitemap URLs, including sitemap_index.xml and sitemap*.xml
        if ( preg_match( '/(sitemap_index|sitemap\d*)\.xml$/', $request_uri ) ) {
            unset( $headers['X-Robots-Tag'] );
        }
    
        return $headers;
    } );
    

    Here’s how you can add a filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    After applying the filter, please clear your sitemap cache by following this screencast: https://i.rankmath.com/pipRDp

    Let us know how it goes. Looking forward to helping you.

    Thank you.

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

You must be logged in to reply to this ticket.