Hello,
We apologize for the issue you are facing with the canonical URL mismatch after migrating to WordPress. To resolve this, you can adjust the permalink settings in your WordPress dashboard to ensure that the URLs do not have a trailing slash.
Here’s how you can do it:
- Go to your WordPress dashboard.
- Navigate to Settings > Permalinks.
- Choose a permalink structure that suits your needs, and make sure to select the option that does not add a trailing slash at the end of your URLs.
- Save the changes.
After making these changes, you may also want to check if Rank Math is correctly recognizing the new structure. If the canonical URLs are still not matching, you might need to manually set the canonical URL for specific posts or pages using the Rank Math meta box on the edit screen of each post/page.
If you continue to experience issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further.
Thank you for raising this concern!
Sources:
WordPress Permalink Structure & Changing Individual URLs » Rank Math
Hello,
Please open the pages with the editor, and under the Rank Math SEO Meta box Advanced tab, please check if you’ve set any canonical URL: https://rankmath.com/kb/advanced-tab/
If you see the canonical URL there, please remove this so that Rank Math can generate the self-referencing canonical.
Alternatively, you can use the following filter on your website to set a self-referencing canonical URL:
add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
$current_url= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$canonical = $current_url;
return $canonical;
});
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
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.