Create Canonical Url In My Page


I am developing a website where a page(category) has many subpages.I was advised that the proper implementation should consist of one main page and the rest should lead to canonical urls (supposedly google likes it that way). Has anybody implemented canonical urls with Yii and what design did you follow so they can be managed from backend. Any insiders would be highly appreciated.

Urls : (Main Page) (Sub Page) (Sub Page) (Sub Page)

I would like to set the canonical url to my main page.


You could use UrlManager

2,3,4 will be the id of the sub category

‘Canonical urls’ are not about url structure, they’re about avoiding duplicate content.

That is, if your content on urls


is not the same, you have nothing to worry about.

If for some reason content is the same, you should add

<link rel="canonical" href="" />

to all pages that are duplicates of

You are right ORey. Is there an extension through which I can add canonical URLs ?


registerMetaTag should be enough…

Thanks ORey.

Found the solution :

Yii::app()->clientScript->registerLinkTag(‘canonical’, null, $href);