You are here:  » Canonical linking


Canonical linking

Submitted by stevebi on Thu, 2015-06-18 06:44 in

Hi David,

What should we apply as rel='Canonical' ?

Cheers

S

Submitted by support on Thu, 2015-06-18 07:50

Hi Steve,

Canonical URLs are intended to indicate to search engines that an alternative, preferred version of page exists, so if you make sure that this situation doesn't occur then there is no need to provide a canonical, however there is one scenario where you might want to provide a canonical and that is sorted search results, with the canononical being the equivalent default sorted URL.

This is straight forward to apply within html/header.php simply by checking for &sort in the REQUEST_URL and providing a canonincal with the sort parameter removed. To give this a go, look for the closing </head> tag and insert the following code just before it:

<?php
  
if (isset($sort) && (strpos($_SERVER["REQUEST_URI"],"&sort=")!==FALSE))
  {
    
$canonical str_replace("&sort=".$sort,"",$_SERVER["REQUEST_URI"]);
    print 
"<link rel='canonical' href='".$canonical."' />";
  }
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Fri, 2015-06-19 10:01

Hi David,

Thank you very much for your reply!

Have a nice weekend!

Cheers

S