You are here:  » Setting canonical URLs in header.html

Support Forum



Setting canonical URLs in header.html

Submitted by juiank on Mon, 2012-05-21 07:06 in

Hello David,

I hope you are well.

I have now two price tapestry sites, one is for desktop browsing and the other is for smartphone.
Their URLs look like this :

http://shop.example.com/ (for Desktop)
http://shop.example.com/m/ (for Smartphones)

I would like to set "rel="canonical" attribute in header section of all pages in http://shop.example.com/m/ , telling search engines that those pages are copies of Desktop versions.
Should I do something like obtaining current URL, remove "/m/ and printing it in "href=" ?

Your advice is greatly appreciated.

Kind regards,
Juliank

Submitted by support on Mon, 2012-05-21 07:58

Hi Julian,

Sure - you could add the following to m/includes/header.php just before the closing <head> tag...

<link rel='canonical' href='<?php print str_replace("/m/","/",$_SERVER["REQUEST_URI"]); ?>' />

Cheers,
David.
--
PriceTapestry.com

Submitted by juiank on Mon, 2012-05-21 11:05

Hello David,

It worked ! Thanks a lot for your great support.
I am really lucky to have chosen Price Tapestry !

Cheers,
Julian