Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
Could you please go to WordPress Dashboard > Settings > General, and make sure that the “WordPress Address” and “Site Address” have the same setup?
Meaning both URLs have the same exact protocols with the trailing slash. They should be matching and not have a mismatch.

If those are already set up, please go to your WordPress Dashboard > Settings > Permalinks and click save changes without making any changes.
Let us know how this goes.
Thank you.
Hi Reinelle,
Thanks for the quick response.
I tried but it didn’t work.
My Permalink Structure is without trailing slash ‘/’
https://www.insecure.in/blog/%postname%
FYI
Earlier when I was using different theme I’ve added ‘rank_math/frontend/canonical’ filter to fix this in themes function.php file and it was working fine.
But now I am using Twenty Twenty Three wordpress theme which does not have functions.php to add this filter.
Please suggest.
Regards,
Prasanna
Hello,
Thank you for getting in touch and we are sorry to hear about the issue you are facing.
You can also use the plugin below to add custom filters on your theme without having the need to use the funcions.php:
https://wordpress.org/plugins/code-snippets/
This way, you can always have the code without worrying about losing it when you switch themes.
Here’s the code to which you can forcibly add a trailing slash to your canonical URL:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
return trailingslashit($canonical);
});
Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.
Thanks Jeremy
It worked with code-snippets plugin.
Can you please share filter code to override home page url in sitemap?
Regards,
Prasanna
Hello,
Please try this filter to force removing all the trailing slashes:
add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
$url['loc'] = untrailingslashit( $url['loc'] );
return $url;
}, 10, 3 );
Make sure to clean your cache and resave the permalinks (just press the save button) so the sitemaps are regenerated.
This filters all your URLs before adding them to the sitemap to make sure they have the trailing slash removed.
Let us know how this goes.
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.