Magento – Remove unnesessary URL rewrites

url

I'm trying to leave just one type of URL for product pages, it looks like this:

http://example.com/category/subcategory/product-name

But Magento automatically creates two more:

http://example.com/product-name
http://example.com/category/product-name

How to prevent this?

enter image description here

I tried truncating core_url_rewrite table and reindexing catalog, but it doesn't help.

(question continues my previous thread in which I've found how to make desired URL type default one)

Best Answer

You can prevent these paths from being generated in the first place - there's a setting in the admin:

System > Configuration > Catalog > Catalog > Use Categories Path for Product URLs:

Set this to No. A reindex of core_url_rewrite table should remove any unwanted urls.

Warning: This will remove all of the category names from all URLs, leaving only the base URL key. There's no way that I'm aware of to perform the opposite - provide only the deepest-depth URL as the canonical URL.

enter image description here

Magento creates these 'pages' by default in the site root and in all relevant categories to provide logical directory structure of product pages within any category as well as standalone pages in the site root.

My suggestion: leave them enabled.

Having descriptive URLs to If you're concerned about duplicate content, you shouldn't be. You should instead enable the setting to display canonical meta tags - this will notify search engines which of the multiple pages you consider to be the de-facto standard page, which all other duplicate product pages are based on.

Below the option as displayed above in the admin is the option to enable canonicals.

Related Topic