Magento: Rewrites for deeply nested category pages

We are doing some SEO optimizations on our Magento store front and I need some advice on the best way to change category urls. Our SEO contractors want to change a bunch of urls from:




We have a bunch of nested categories (5 top-level and a bunch of sub categories up to 4 levels deep). Since this helps our customers drill down through the main navigation, we aren’t sure if we want to change the category hierarchy. But we might be doing these url changes on 100 categories or so.

I know we can do part of this with using 301 rewrites (using .htaccess or Magento’s built-in rewrite module), but what is the best way to approach this? One of the drawbacks I see to using 301s is that the main navigation will continue to have the long, sub category url in it’s link. Should I look at doing a custom module that allows us to specify an exact url for categories (rather than a url token specific to the hierarchy)? What is your advice?

One thought on “Magento: Rewrites for deeply nested category pages”

  1. More than likely you’re going to want to write a script to do this for you and keep it within Magento’s URL Management instead of some long un-manageable list of rewrites/redirects in .htaccess or such.

    Your biggest issue I would think would be any collisions where the same filename exists and how you would want to handle such.

    ->setIdPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')
    ->setTargetPath($categoryModel->getUrlPath() . '.html')
    ->setRequestPath('index.php?cat=c' . $categoryId . '_' . $this->strip($data['name']) . '.html')

    This is just an example of how to add rewrite’s into Magento’s URL Rewrite Manager.

Leave a Reply

Your email address will not be published. Required fields are marked *