Hi using info from this site and around the web I have started to add hreflang tags to my magento store. They work and display as they should on the default (American)site, however on the alternate (Canadian)site it does not work, here is the code & how it displays.
<link rel="alternate" href="http://www.example.com<?php
$urlString = Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($urlString);
$path = $url->getPath();echo $path
?>" hreflang="en-us" />
<link rel="alternate" href="http://www.example.com/ca<?php $urlString =
Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($urlString);
$path = $url->getPath();echo $path ?>" hreflang="en-ca" />
which on the main site properly displays as (on a product page for example)
<link rel="alternate" href="http://www.example.com/sample-product.html"
hreflang="en-us" />
<link rel="alternate" href="http://www.example.com/ca/sample-product.html" hreflang="en-ca" />
so far so good, however when you are on the Canadian ca site, it now displays as
<link rel="alternate" href="http://www.example.com/ca/sample-product.html" hreflang="en-us" />
<link rel="alternate" href="http://www.example.com/ca/ca/sample-product.html" hreflang="en-ca" />
as you can see there is an extra (/ca/) on each url. I'm not quite sure how to tackle this problem, I guess what I need is the code to output everything after the base url as opposed to the domain of each site. Any help that you could provide will be greatly appreciated! Thank you.