The canonicalLink on product pages gets created on line 43 of includes/init_includes/init_canonical by
zen_href_link
Code:
39 /**
40 * for products (esp those linked to multiple categories):
41 */
42 case (strstr($current_page, '_info') && isset($_GET['products_id'])):
43 $canonicalLink = zen_href_link($current_page, ($includeCPath ? 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id($_GET['products_id'])) . '&' : '') . 'products_id=' . $_GET['products_id'], 'NO 43 NSSL', false);
44 break;
This function is defined in includes/functions/html_output.php. The problem is that just before returning, the URL gets sanitized on line 94 replacing & with &
Code:
94 $link = preg_replace('/&/', '&', $link);
The result in the document head is like
Code:
<link rel="canonical" href="http://example.com/index.php?main_page=product_info&products_id=1" />
instead of
Code:
<link rel="canonical" href="http://example.com/index.php?main_page=product_info&products_id=1" />
Google bot then attempts to follow the link which triggers missing resource (404) on the webserver.
Any suggestions how to fix this with minimal effort? I could add yet another argument to zen_href_link and use it to escape the sanitization, but may be there's a better way. May be there is no need to use zen_href_link at all to create that link, but I am very unfamiliar with zen-cart to know whether that's really the case.
Bookmarks