PDA

View Full Version : SEO URLs and Canonical link



Luxoria
04-25-2011, 01:07 PM
Assuming a product URL of /name-p-1.html is indexed by the search engines then the store admin changes the name of the product and the new URL is /newname-p-1.html, considering how the rewrite system works, would not the search engines see both URLs as separate URLs? If so, this will be considered duplicate content.

If this is the case of duplicate URLs indexed, a solution would be to use the canonical link. However, the canonical link generation code does not pass the URL through the SEO URLs modification and the information provided in the address bar is the basis of the canonical URL. So the canonical URL is still the OLD product name.

Before I take the time to create the code to generate a canonical URL based on the product/category IDs and running it through the SEO URLs mod (thus generating a consistent URL no matter what the referring URL is) I want to make sure my thinking is correct.

Luxoria
04-26-2011, 01:22 AM
If anyone else has the same concern and would like a temporary solution here's a quick hack that works for product and category pages.

At the end of meta_tags.php find...


// BOF: Remove & Prevent duplicate content with the canonical tag V1.3.2
CanonicalLink( $xhtml = false, 'SSL' );
// EOF: Remove & Prevent duplicate content with the canonical tag V1.3.2...and replace with...


//LUX MOD - TEMP HACK TO FIX DUPLICATE URLS
if ($content == CONTENT_PRODUCT_INFO) {

echo '<link rel="canonical" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $mt_product_info['products_id'], 'NONSSL', false) . '">';


} else if ($content == CONTENT_INDEX_PRODUCTS) {

echo '<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' .(int)$current_category_id, 'NONSSL', false) . '">';

} else {

// BOF: Remove & Prevent duplicate content with the canonical tag V1.3.2
CanonicalLink( $xhtml = false, 'SSL' );
// EOF: Remove & Prevent duplicate content with the canonical tag V1.3.2

}This code with now generate a canonical link based on the product ID so even if the referring URL was example.com/product_info.php?products_id=63 the canonical link will now be example.com/productname-p-63.html, yay.

Well, all this may not even be necessary, considering when I searched Google for URLs of OLD versions of a products I know was at one point indexed the search results shows the new URL. Any insight why/how google was able to determine the actual/new URL would be great!

For me my assumption is this hack should help removed none SEO URLs that were indexed because of a site map misconfiguration.

Does any of this make sense or have I've been drinking too much on the job?

tcshadow
05-05-2011, 07:35 PM
From my experience, if you change the name of the product all of the old links, and any randomly worded links that have the accurate product ID will still work.

So for example:
example.com/productname-p-63.html
example.com/productnickname-p-63.html
example.com/productothername-p-63.html
example.com/productrandomname-p-63.html
example.com/-p-63.html
example.com/product_info.php?products_id=63

will all rewrite to your new, current
example.com/newproductname-p-63.html

I'm not sure what redirect the rewrite assigns, whether it's a 301 or 302 or something else, but when google tries to respider your site and goes to

example.com/OLDproductname-p-63.html
and the spider is redirected to
example.com/NEWproductname-p-63.html

Google will reassign any links it has in it's index that point to

example.com/OLDproductname-p-63.html

and they will be allocated to

example.com/NEWproductname-p-63.html so you will maintain your ranking for that keyword and it will point to the new URL.

I had this happen recently when I added a word to the URL for SEO purposes... The keyword actually completely dropped from the index for about 3-4 days and then appeared at a higher position with the new URL.

tcshadow
05-05-2011, 07:46 PM
Actually as it turns out, I was wrong. It doesn't redirect to the new url... but Google finds it anyway. Might be because of my sitemap... old url disappeared and a new one with the same content was there.