lunedì 14 novembre 2011

Experimenting with link rel canonical

One year ago i put a sitemap on google to fix the problem of the duplicate page caused by the way typo3 manages urlvars. I have found this is not the correct solution for a growning and changing site...
does not work very well and constant repopulation of the map is needed as new parameters value compare.

So, since now i know how to revrite header on any page, i am trying a different solution.

I'm going to setup this for root pages (level 1).

Again lumo php record is the main tool.

Here is a sample code:

<?php
$fid = $_GET['FID'];
$canurl='http://www.felixweb.it/galleria_foto_gatti.php';
$imgg="galleria_gatti_thmb.JPG";
$title="FELIX - la galleria : foto e immagini dei gatti più belli degli allevamenti e degli amici di FELIX";
$GLOBALS ['TSFE'] -> additionalHeaderData ['100 '] ='<meta property="og:title" content="'.$title.'" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['101 '] ='<meta property="og:type" content="website" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['102 '] ='<meta property="og:url" content="'.$canurl.'" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['103 '] ='<meta property="og:image" content="http://www.felixweb.it/public/fileadmin/user_upload/gallery2/thumb/'.$imgg.'" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['104 '] ='<meta property="og:site_name" content="FELIX il portale del gatto" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['105 '] ='<meta property="fb:admins" content="1466516534" />';
$GLOBALS ['TSFE'] -> additionalHeaderData ['106 '] ='<link rel="canonical"  href="'.$canurl.'"/>';

?>

As you can see i have setup all parameters in variable at the beginning of the code.  Next you can find header for facebook, always useful, and is good to do all headers work on the same place to avoid indexing problem (if a second script write another additionalHeaderData ['105 '] this one will be lost!

The last HeaderData (number 106) is the link rel canonical one. As you can see i am using a speaking url as canonical...

I hope this solution works well... i will keep you informed!

Nessun commento:

Posta un commento