-
I have added Math Sitemap Rewrite Rules but my sitemap does not redirect to the main sitemap URL.
I have also added code in my WP rocket
/(.*)sitemap(.*).xml/
/(.*)sitemap.xsl/
-
Hello, I’m sorry to hear that you’re experiencing issues with your sitemap redirection. It seems like you’ve added the necessary rewrite rules for Rank Math sitemaps and also configured WP Rocket to exclude the sitemap from caching.
Since you’ve already added the rewrite rules and excluded the sitemap from caching in WP Rocket, it’s possible that there might be an issue with the configuration. To ensure that everything is set up correctly, could you please check if the rewrite rules are correctly added to your server configuration file?
If you’re using an Nginx server, please ensure that the rewrite rules have been added to the Nginx config file as shown in the following screenshot:
If you’re using an Apache server, please verify that the rewrite rules have been added to the .htaccess file as shown in the following screenshot:
Once you’ve confirmed that the rewrite rules are correctly added, please check if the sitemap redirection issue persists. If it does, feel free to reach out to us by replying to this ticket, and we’ll be happy to assist you further.
Thank you for your understanding and patience.
Sources:
Rank Math Sitemap Issues and Their Fixes » Rank Math
Rank Math XML Sitemaps on NGINX Servers » Rank Math
Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
How To Exclude Rank Math Sitemaps from Caching » Rank MathHello,
Thank you for your query, and we are so sorry about the trouble this must have caused.
For initial troubleshooting can you please try following the steps below to see if that works for you?
#1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp#2. 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, please follow this article ( if you use caching plugins ) :
https://rankmath.com/kb/exclude-sitemaps-from-caching/For Cloudflare, please follow this article ( if you use cloudflare ) :
https://rankmath.com/kb/exclude-sitemaps-from-caching/#cloudflare#3. If the above steps doesn’t seem to work, kindly apply the following filter code to your site.
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
Here’s how you can add filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/We hope that helps, and please don’t hesitate to get in touch if you have any other questions.
Thank you.
Thanks for reply
I have idea of coding.
Please could you provide me full written code? when I add this (add_filter( ‘rank_math/sitemap/enable_caching’, ‘__return_false’);)
this code not working please help me.
Thank you
Hello,
This is the complete code. You just need to add the code at the very bottom of your theme’s functions.php file just above the closing ?> (if any).
Then it’ll work fine for you.
Thank you.
Hello,
I added this code at the very bottom of my theme’s functions.php file But the problem has not been solved. I have tried all methods but no one is working. What I do please guide me.
Thank you
Hello,
Your sitemap appears to be generating correctly at https://yourdomain.com/sitemap_index.xml (see sensitive data section)
We equally tested it using https://www.xml-sitemaps.com/validate-xml-sitemap.html and found no errors.
We hope this helps. Please let us know if you have further questions or concerns.
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.
The ticket ‘Please help me to solve sitemap problem’ is closed to new replies.