Remove duplicate categories urls.

Январь 13, 2011

I’ve discovered that WordPress generates the same category page for and which is not so good for SEO. The possible quick fix that worked for me — to add to the theme’s header.php the following code:

if (is_category())
	list($dummy, $categoryRelative) = split("category", $_SERVER["REQUEST_URI"]);

	$category_id = get_cat_ID( single_cat_title("", false) );
	$category_link = get_category_link( $category_id );

	list($dummy, $correctCategoryRelative) = split("category", $category_link);

	if ($categoryRelative != $correctCategoryRelative)
		header('HTTP/1.1 301 Moved Permanently');
		header('Location: '.$category_link);

This is a really quick code — if you can suggest a better solution, please do!

tags: ,
posted in wordpress by dmitko

1 Comment to "Remove duplicate categories urls."

  1. Find Duplicate Files wrote:

    This is really fascinating, You’re an overly skilled blogger.
    I’ve joined your rss feed and look ahead to seeking more of your great post.
    Additionally, I have shared your site in my social networks

Powered by Wordpress and MySQL. Theme by Shlomi Noach,