-
Hi RankMath,
I have used RankMaths “redirection” (301) function for pages like this:
mydomain.com/category/bicycles > mydomain.com/bicycles
So the category pages are redirecting to pages that I have more control of.
The problem is that in the sitemap, the URLs for the categories are the old ones: mydomain.com/category/bicycles
I would like to change these category URLs in the sitemap, to the URLs that they are redirecting to.
I have:
– Free version of RankMath
– Updated WordPress, theme and RankMath to the latest versions
– Flushed both server and WordPress cachesIt’s been like this for maybe 1 month, so it doesn’t seem to be updated automatically.
How do I change these category links in the Sitemap?
Thanks in advance.
Best regards,
Zbigniew
-
Hello,
Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.
Rank Math’s sitemap won’t be able to see the redirected category and it would still include the category base on the sitemap.
Please head over to your WordPress Dashboard > Rank Math > General Settings > Links and enable the option “Strip Category Base”.
See if that works on your end.
Looking forward to helping you.
Hi Jeremy,
Thank you for the quick reply.
Unfortunately, I can’t strip the base. Because the slug is identical in the categories in an the page they are redirecting to.
It looks like this:
mydomain.com/category/blue redirects to mydomain.com/blueSo when I strip the category, it will send me to the standard category page.
Is it possible to manually change the sitemap to solve this?
Thanks in advance and have a nice weekend!
/Zbigniew
Hello,
Could you please let us know which “standard” category page are you referring to? If I understand correctly, if you are to remove the category base, different content will be shown?
With that said, we have many available filters that may help you modify your sitemap. Please refer to our KB guide here: https://rankmath.com/kb/filters-hooks-api-developer/#sitemap
Looking forward to helping you on this one.
Hi,
It means that if I strip the category base, it won’t redirect. You can’t have two identical slugs.
I read your link, but couldn’t find anything that is related to my problem. Which number/headline on that page are you referring to, that would help in this case?
Thanks.
I believe he is referring to the KB guide 6. Filter sitemap item before it gets added to the sitemap.
Perhaps if you provide a visual example or a link it may be easier to understand, but what I gather is:
- mydomain.com/category/bicycles |301 redirects to| mydomain.com/bicycles
- Strip Category Base makes mydomain.com/category/bicycles into mydomain.com/bicycles
- But Strip Category Base also makes mydomain.com/category/blue into mydomain.com/blue, and you don’t want that.
So by using the documentation “6. Filter sitemap item before it gets added to the sitemap.”, you can
- Check if URL = mydomain.com/category/bicycles
- Change to mydomain.com/bicycles
- Submit new changed URL to sitemap instead
For a simple off-the-top of my head solution, download the plugin “Code Snippets” and add a Snippet with the following as a safer way to add code snippets.
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){ if (strpos($url, 'mydomain.com/category/bicycles') !== false) { $url = str_replace( '/category', '', $url ); }; return $url; }, 10, 3 );Hello @silvette,
The filter you shared will indeed help us modify the URL structure before being inserted to the sitemap.
Thank you so much for sharing your input here.
Once you strip the category base, the old category URL should automatically be redirected to the new one. You don’t have to create a redirection rule for it via Rank Math. Can you please confirm if that wasn’t the case on your end?
If so, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress login in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
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.
@Silvette
Thank you for the suggestion. I will look into that. Hopefully it can solve the problem. I showed my URL in the open post, but only so that admins can see it.
@Jeremy
But how do you redirect from an identical URL to another?
I.e mydomain.com/blue -> mydomain.com/blueWhen I strip the category base simply nothing happens. No redirect. The user will only see the category, and not page that I want it redirected to.
I must have missed something crucial in that case. How do you mean I can send the user from /blue (the category) to /blue (the page)?
Thanks.
Hello,
Please note that our sitemap doesn’t filter out the pages with redirections and that’s why you are seeing the category page being shown there.
If you would like to remove the category page you need to set the page to
noindexin the settings.Hope this helps clarify the situation.
Don’t hesitate to get in touch if you have any other questions.
Hi Miguel,
Thanks for your input.
But my initial question still stands; “How do I change these category links in the Sitemap?”
Is it not possible?
Hello,
But how do you redirect from an identical URL to another?
I.e mydomain.com/blue -> mydomain.com/blueWhen I strip the category base simply nothing happens. No redirect. The user will only see the category, and not page that I want it redirected to.
I must have missed something crucial in that case. How do you mean I can send the user from /blue (the category) to /blue (the page)?
In these cases, the behavior would remain unexpected as the URLs will conflict. If you wish, you can slightly modify the slug of either of the URLs to easily fix the issue.
But my initial question still stands; “How do I change these category links in the Sitemap?”
If you’ll choose the modify the slug, the correct URLs without the base would be added to the sitemap.
In case the sitemap doesn’t update, please follow the below steps and see if that helps:
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp2. 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/3. Clear your website and browser’s cache and check the sitemaps again.
Hope this helps.
Thank you.
You are a hero, Silvette!
1 week and 3 different support staff – and still no answer to my question.
But your solution worked perfectly! Thanks a lot for that. You made my day!
Hello,
We are glad that your issue has been resolved and we apologized that it took some time to address the issue.
The filter codes we provided require further customization as suggested by Silvette.
With that said, please do not hesitate to let us know if you need our assistance with anything else.
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 ‘Sitemap links to pages that have a redirect’ is closed to new replies.