cancel
Showing results for 
Search instead for 
Did you mean: 

Big number of custom redirects set up in the rewrite rules

Big number of custom redirects set up in the rewrite rules

Hi,

 

I've noticed a big number of custom redirects. The are not set up by anyone in the company, at least this is what everyone says. The have form of name-7698.thml to name-7699.html, so completely random. 

 

Can custom redirect be not set up by a person but be a side effect of the system processes? How to find out what's going on.

 

Thanks a lot for your help,

Kamala

5 REPLIES

Re: Big number of custom redirects set up in the rewrite rules

Redirects in Catalog => URL Rewrite Management are not usually created manually although the column Type says it is a “Custom” redirect. The rewrites that appear on that list are mostly created during normal product creation or modification.

 

When you save a product, a friendly URL is created with format “name-of-the-product.html”, and some redirects are automatically created (in fact, more than one are created for each product).

 

Also if you go to edit any product on your shop, below the field URL Key you’ll see a checkbox “Create permanent redirect for old URL”. If you change the URL Key of a product and the checkbox is set, a redirects are created as well.

 

Sometimes, if you have two products with the same name, the URL Key that is automatically created yet exists in the system.

To avoid duplication, Magento adds the product id at the end, and the URL looks like “name-of-the-product-1234.html”

Re: Big number of custom redirects set up in the rewrite rules

I agree that this is the duplicate URL key case.

 

Actually, such situations are rather frequent. Magento doesn't enforce URL key uniqueness, so almost every website that I have worked with, has at least several products with the same URL key. Magento does solve that by adding some extra numbers to the URL, but there is another problem - URL rewrite reindex.

 

Each time you make URL Rewrite reindex (by yourself or by cron), Magento creates new rewrites for such products (with non-unique URL key) with the new extra numbers, but it doesn't clean old rewrites. Such behavior increases the amount of records in the core_url_rewrite table after each reindex which isn't good for website performance. For example, recently we were investigating low performance on one of our customer's website and found out that it was because of enormous amount of records in the core_url_rewrite table - 2 millions instead of 150 thousands (sorry, incorrect numbers due to the bad memory) 12 millions instead of 1.6 million. After each reindex it was increased by about 90 thousands. After cleaning the extra records and enforcing URL key uniqueness, performance became much better. This is a rare case and if you don't have many products with non-unique URL keys, it won't affect performance on your website, but it doesn't mean that you don't have the problem.

 

And by the way, categories have similar problem. Unlike products, it is ok if you have some categories with the same URL key, but only if they are not in the same parent category. But if they have one parent, that will lead to incorrect reindex as well.


ET Web Solutions
extensions, custom work, support

Re: Big number of custom redirects set up in the rewrite rules

Hi guys,

 

I have similar problem. core_url_rewrite table is ~42000 in size for ~7000 SKUs ant it adds around 1,5 seconds for every page load.

 

I've tried turning Use Category Name in URL parameter in SEO settings off, but it didn't help. Indexer still generates URLs like:

 

39611  Sistema  product/3547/152  aksesuarai/kuprines/kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547/category/152

39610  Sistema  product/3547/41  aksesuarai/kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547/category/41

39609  Sistema  product/3547  kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547
29633  Sistema  product/3547/152  aksesuarai/kuprines/kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547/category/152
29632  Sistema  product/3547/41  aksesuarai/kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547/category/41
29631  Sistema  product/3547  kuprine-shimano-unzen-2-3547  catalog/product/view/id/3547

 

As you can see it still generates categories and subcategories in URLs. Also it generates URLs for different shop's language views even if the view is disabled.

 

How to force Magento to respect "Use Category Name in URL" parameter?

 

I've browsed for two days now on the net, tried every possible "fix" I could find - custom Url.php patches, different SEO settings, truncating core_url_rewrite multiple times - but non of them helped.

 

I'm using Magento CE 1.9.1.1.

Re: Big number of custom redirects set up in the rewrite rules

Hi vilius,

 

Actually, if I'm not missing something, I think that your situation is pretty normal. I believe, "Use Category Name in URL" parameter is used only for generating the URLs in the frontend. Probably you can force Magento to generate the URLs for the Url Rewrite Index only with category names with it, but it doesn't make any sense.

 

The product in Magento can be in several categories at the same time. So when you go to some category on the frontend, all products on this page will have this category in the URLs. When you go to some other category, all products will have that category in their URLs even if both categories have the same products. But when you search for something and view search results, all products won't have any category in the URLs because Magento doesn't know which of the categories, that product belongs to, should be used for the URL - so Magento doesn't use any (in your case it is http://sitename/kuprine-shimano-unzen-2-3547.html). And if you don't have such URL in the table, you'll get 404 error. Probably, there are some extensions that change the way it works, but I don't know any.

 

Anyway, 42000 is pretty normal. Url Rewrite Indexer creates rewrites for every category where this product is. So one of the ways to reduce this number is to assign products only to the end categories (in your case - "kuprines") and make the parent categories ("aksesuarai") as landing pages. But this is a lot of work and usually isn't worth it.


ET Web Solutions
extensions, custom work, support

Re: Big number of custom redirects set up in the rewrite rules

Thank you. It seems I have misunderstood what "Use Category Path in URL" means. It is valid for URL path, but as you correcly pointed out my issues is with ID keys. Indexer creates multiple of them for every category/sub-category.

 

I found a workaround though. In file /app/code/core/Mage/Catalog/Model/Url.php on line 863 (for CE 1.9.1.1) find and comment out:

if ($category && $category->getLevel() > 1) {
    return 'product/' . $product->getId() . '/' . $category->getId();
}

This is just under path_id creation condition.

 

Now indexer generates only one ID key for every product - "product/key".  And it also creates just one URL in a form of "category/subcategory/product"

 

Obviously it will only work if "Use Category Path in URL" is set to NO in SEO settings.