Magento Forum

   
Canonical url’s without extension Yoast
 
Ella S.
Jr. Member
 
Total Posts:  21
Joined:  2009-06-29
 

I couldn’t get yoast module canonical url’s to work. So I fixed it the hard way. For future reference, and for getting maybe some feedback, here is what I did.

In layout/catalog.xml:

<catalog_product_view>
        <
reference name="head">
            <
block type="page/html" name="canonical" template="catalog/product/canonical.phtml" />
...
        </
reference>
</
catalog_product_view>

Then I created templates/catalog/product/canonical.phtml:

<?php
    $ella_r 
preg_replace('/^.*\/(\w*\.html)$/','$1',$_SERVER['REQUEST_URI']);
    if (
$ella_r != $_SERVER['REQUEST_URI']{ ?>
<link rel="canonical" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).$ella_r; ?>" />
<?php } ?>

I suppose that there are better ways. Feedback is welcome.

Kisses.
Ella S.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3215
Joined:  2009-02-26
Minneapolis MN
 

Thanks Ella, I am going to give it a shot.
double kisses back

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mirasvit
Guru
 
Avatar
Total Posts:  638
Joined:  2009-08-22
 

hi! As a variant, you can try the ready SEO extensions. Check this one http://mirasvit.com/magento-extensions/advanced-seo-suite.html

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top