Zen Cart Logo
Forums / Search Engines / Canonical Categories

Canonical Categories

Views: 522

Results 1 to 5 of 5
7 Dec 2011, 3:51 PM
#1
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Canonical Categories

I am having an issue with canonical category links.

It was caused by moving a category into another one.

In this case category 116 was moved inside category 66.

/index.php?main_page=index&cPath=1_116_112
/index.php?main_page=index&cPath=1_66_116_112

Each one of these url versions gives the Canonical Tag of itself.

How can I get this

-> /index.php?main_page=index&cPath=1_116_112

to show a canonical tag of this

-> /index.php?main_page=index&cPath=1_66_116_112

I have about 3500 URLS that were affected.

Thanks in Advance

7 Dec 2011, 5:03 PM
#2
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Canonical Categories

Here's what I've come up with so far, Please let me know if this is not a solid solution, or if i've missed something.

In the init_canonical.php i changed this

case ($current_page == 'index' && isset($_GET['cPath'])):
    $canonicalLink = zen_href_link($current_page, zen_get_all_get_params($excludeParams), 'NONSSL', false);
    break;

to this

case ($current_page == 'index' && isset($_GET['cPath'])):
	$canonicalLink = zen_href_link($current_page,'cPath=' . zen_get_generated_category_path_rev($current_category_id) , 'NONSSL', false);
    break;

This appears to allow me to move around categories on my site and reflect the proper canonical link automatically.

~D

25 Apr 2014, 5:47 PM
#3
hunteryz avatar

hunteryz

Inactive

Join Date:
Oct 2013
Location:
120 Wilshire Blvd,Brentwood,NY,11717
Posts:
94
Plugin Contributions:
0

Re: Canonical Categories

Interesting Issue

I have no idea how to fix that,
Waiting zen pros

But what i know is Changing URL will hurt the previous URL Ranking Power,
Your changing on the category could be drop down your category ranking

28 Apr 2014, 1:57 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Canonical Categories

If category 116 is now under category 66, the cPath 1_116_112 is no longer valid (it will give an incorrect category path). However, you can enter an incorrect path and still reach the final category. Rather than silently redirect the incorrect URL, I think you need to use a 301 redirect to alert search engines that the category is moved permanently. They will soon adjust their search results and people will no longer be given the old URL. A redirect expert can tell you the exact code to manage that; it would probably go in your .htaccess file.

28 Apr 2014, 12:37 PM
#5
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Canonical Categories

Although the code above does solve that issue.

I agree with gjh42, a 301 is the best way to go.

Your redirect would look something like this.

RewriteCond %{THE_REQUEST} .*/index.php [NC] 
RewriteCond %{QUERY_STRING} ^main_page=index&cPath=1_116_112$ [NC] 
RewriteRule ^(.*)$ http://www.YOURDOMAIN.com/index.php?main_page=index&cPath=1_66_116_112 [R=301]