Sitemap URL Redirecting to Homepage / 404 Error

#1101742
  • Hello Rank Math Support Team,

    I am experiencing an issue with my sitemap. When I click on my sitemap link, it shows a 404 error and redirects to my website’s homepage:

    Sitemap URL: https://vitrisites.com.br/sitemap_index.xml

    Because of this, I am unable to submit my sitemap to Google Search Console.

    I would like to mention that previously I was using the Yoast SEO plugin, and the sitemap was working correctly. After switching to Rank Math SEO, this issue appeared.

    If you need access to any internal files of my website, such as server files, WordPress files, or WordPress admin, please let me know exactly which permissions and accesses are required.

    Could you please help me resolve this issue?

    Thank you in advance for your support.

    Best regards,

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

    We apologize for the issue you are facing with your sitemap. A 404 error when accessing your sitemap can often be resolved by flushing your permalinks. Here’s how you can do that:

    1. Go to your WordPress admin area.
    2. Navigate to Settings → Permalinks.
    3. Click the Save Changes button, even if you didn’t make any changes on the page.

    Flush permalink settings

    This should help resolve the 404 error. If the issue persists, please check if your server is configured correctly to handle the sitemap. You may need to add rewrite rules to your .htaccess file if you are using an Apache server or your Nginx configuration file if you are using Nginx.

    For Apache, add the following code to your .htaccess file:

    # 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

    For Nginx, add the following code to your configuration 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

    If you continue to experience issues, please reply to this ticket with any relevant details or access permissions needed for us to assist you further. A human agent from our support team will take over and provide more specific guidance.

    Thank you for raising this concern, and we look forward to helping you resolve it!

    Sources:
    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,

    You seemed to have marked this ticket as resolved.

    We’re just following up with you to see if you have any other questions or concerns that we can assist you with. Or, if your issue has been resolved, please let us know so we can mark this ticket as closed.

    Thank you for choosing Rank Math.

    I got here through a Google search for how to fix the same error. And saving the permalinks worked for me. Thanks for the help.

    Hello @ardiueredeu,

    Thank you for reaching out to us and for sharing your solution.

    If saving the permalink settings resolves the issue, this indicates heavy caching on your sitemap, and this issue could happen again in the future.

    In this case, you can follow the steps below to ensure your sitemap is free from caching:

    #1 Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    #2 Apply the following filter code to your site.

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

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

    Hope that helps.

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

You must be logged in to reply to this ticket.