sitemap.xml not redirecting to sitemap_index.xml

#520653
  • Resolved Anisa Begam
    Rank Math free

    My website’s sitemap is made with rankmath plugin but when I try to open my sitemap with sitemap.xml so it is not automatically redirecting to sitemap_index.xml. I changed my htaccess file with the default file to make sure there is no problem with my htaccess file. Even I also tried to deactivate all plugins except Rank Math still the issue is occurring.
    So, please check and fix this issue. Other details are given in sensitive data section.

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

    Thanks for contacting us, and sorry for any inconvenience that might have been caused due to that.

    If /sitemap.xml is not redirecting to the default /sitemap_index.xml, you may need to apply this fix on your site:

    For Nginx: https://rankmath.com/kb/sitemap-404-error/#num-3-2-1-add-rewrite-rules-to-nginx-server
    For Apache: https://rankmath.com/kb/sitemap-404-error/#num-3-2-2-add-rewrite-rules-to-apache-web-server

    You may also ask your hosting provider to do that for you.

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

    Thank you.

    The article that you shared with me is about solving an error about sitemap_index.xml showing 404 but my issue is that my sitemap.xml is not working or redirecting to sitemap_index.xml
    Can you help me with this issue?

    Hello,

    Rank Math generates Sitemap on the fly when you enable that module, and we rely on redirects enabled by your server software to accomplish that. If the redirection with the sitemap doesn’t work, you may have to add some rewrite rules to them in order to function sitemaps properly. The rules I’ve shared above, should work in your case as well.

    However, it’s not necessary to have a 301 redirection from /sitemap.xml to /sitemap_index.xml, since the actual sitemap is being generated at /sitemap_index.xml. Which perfectly fulfills the required job of sitemap. That won’t have any negative impact on your SEO, and you can simply submit /sitemap_index.xml to GSC. That should work fine without any issues.

    Looking forward to helping you.

    Thank you.

    You say that may I have to add some rewrite rules to them in order to function sitemaps properly. The rules that you have shared above, should work in your case as well. So, where you shared the rules above? Can you share again so that I can add these rewrite rules. Also tell me where to add them and how to add them in my website.

    Hello,

    # If you’re using an Nginx server, you need to add the following rewrite rules to fix this:

    # 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

    Here’s an article you can check: https://ubiq.co/tech-blog/rewrite-url-parameters-nginx/

    # If you’re using an Apache web-server, you need to add the following rewrite rules to fix this:

    # 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

    Here’s how you can edit .htaccess file using Rank Math:
    https://rankmath.com/kb/edit-htaccess/

    Please do take a backup before editing your .htaccess file.

    If that seems to be complicated for you, please get in touch with your hosting provider to see if they can do that for you.

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

    Thank 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 5 replies - 1 through 5 (of 5 total)

The ticket ‘sitemap.xml not redirecting to sitemap_index.xml’ is closed to new replies.