[OFFER ALERT!] This Halloween, Get Any Premium Theme for Just $19 [GET IT NOW]
Jump to content

[Rank Math SEO Plugin] Change canonical URL (again)


Marcus_Tang
 Share

Recommended Posts

Hello,

I know this topic has been discussed, but I couldn't find the answer in the other posts.

RankMath shows my canonical url as https://domain.com but I have set it to https://www.domain.com everywhere else.   I have found the following line on my site:

<link rel="canonical" href="https://domain.com">

I am unsure where this line is being created and why it's set to the non WWW version.  I am using the latest Wordpress.

Is there a simple way to change this canonical URL reference from https://domain.com to https://www.domain.com    As Google is now displaying search result as the non-WWW version, which I want to avoid.

Many thanks!

Link to comment
Share on other sites

  • Support

Hello,

I would suggest you to change Site URL which is without www. But if want to change canonical url without changing Site url then please add below filter to your theme's functions.php file:

add_filter( 'rank_math/frontend/canonical', function( $url ) {
	$url = str_replace( 'https://', 'https://www.', $url );
	return $url;
});

Hope that helps. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • Support

Hello,

Thank you for contacting MyThemeShop and sorry for any inconvenience that might have been caused due to that.

Can you please follow the reply from here and let us know in this ticket if that helped?

Looking forward to helping you.

P.S. There's a filter provided here which can help as well

 


🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • Support

Hello,

Can you please confirm the settings from the WordPress's General Settings area?

The plugin picks the data from there.

Looking forward to helping you. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Thanks for getting back to me.   It's a multisite, so I get the settings from Network Admin -> Sites ->

Info Tab:  Site (URL):  https://domain.com

Settings Tab:  Siteurl: https://www.domain.com,  Home: https://www.domain.com

So it seems the culprit is the Site (URL) - or could it be because of the Yoast Plugin (which has now been deactivated by RankMath?

Either way, I would be grateful for your advice on how to change the <link rel="canonical" href="https://domain.com"> to <link rel="canonical" href="https://www.domain.com">

Thank you very much.

Link to comment
Share on other sites

  • Support

Hello,

I would suggest you to change Site URL which is without www. But if want to change canonical url without changing Site url then please add below filter to your theme's functions.php file:

add_filter( 'rank_math/frontend/canonical', function( $url ) {
	$url = str_replace( 'https://', 'https://www.', $url );
	return $url;
});

Hope that helps. Thank you.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

  • Support

Hello,

It was a pleasure helping you. We are glad you found our help useful. If you have any other questions in future, do let us know. We are here to help you.

Could you please leave us a testimonial (if you haven't already done that) on about your overall experience with MyThemeShop? This will help us serve you, our members, better. We appreciate your time and patience.
https://community.mythemeshop.com/forum/6-testimonials/

Thank you in anticipation.


🏁Rank #1 on Google With our WordPress SEO Plugin.

Score a 💯on PageSpeed and Dominate Search Rankings.

✏ Editing theme files? Please create a child theme to make your changes update-proof.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...