Can't change home page Canonical URL

Permalink
hi there

I'm trying to change my home page Canonical URL

fromhttp://www.mydomain.com/ towww.www.mydomain.com/hello/world...

... I can add the new path in the page properties, but when saving I find that it hasn't changed it... just reverts back tohttp://www.mydomain.com/

I have pretty URLs on and working fine for the rest of the site

I'm a newbie so please be gentle ;)

thanks

 
TheRealSean replied on at Permalink Reply
TheRealSean
I did not come up with this it has been bounded about in the forum and I tweaked this to fit my site.

You would add this to your theme header to output a canonical link
<?php
   $canonical = $c->getCollectionPointerID() ? Page::getByID($c->getCollectionPointerID()) : $c;
   $nh = Loader::helper('navigation');
      /* If this page has the attribute replace_link_with_first_in_nav then redirect to that page instead */
   if ($c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
         $subPage = $c->getFirstChild();
         if ($subPage instanceof Page) {
               $nh = Loader::helper('navigation');
               header ("HTTP/1.1 301 Moved Permanently");
               header ("Location: " . $nh->getLinkToCollection($subPage));
               exit();
         }
   }
   //Change this to be you Canonical URL   
   $canonical = BASE_URL.DIR_REL;


Or if you have you site athttp://www.yousite.com/over/here then you can change the DIR_REL to be the following.

This would actually redirect your site to be this url though so all links would be relative to this. So this would probably require some alterations to your htaccess file also.
define('DIR_REL', 'over/here');