Magento makes it easy to create URL rewrites based on categories, it also makes it easy to make rewrites based on products, but what about attributes?
It’s fairly easy to create a URL rewrite based on attributes, so in this short guide we’ll show you how to create attribute + category combo URL rewrites.
To create a URL rewrite based on an attribute and a category in Magento, you’re going to need three things:
- The category ID
- The attribute code Note: This must be an attribute available for layered navigation for this method to work!
- The attribute value ID
The category ID can be found very simply on the category page in the backend:
The attribute name is simple – it’s the attribute code set in the Magento backend:
Lastly, the attribute value ID. This is a bit trickier, as it doesn’t appear in many places on the front or back-end of the site. Probably the easiest place to find it is by going to a layered navigation page for that attribute value, and it will be in the URL:
It can also be found in two other ways easily, by right clicking on the dropdown/multiselect in the create product page in the backend and looking at the ‘value’ of that select value, or by looking at the value in the database.
Once you’ve got those three things, try going to the following URL:
That should take you to the desired page, filtering that category for that attribute value. If this is all correct, then go to Catalog > URL Rewrite Management and create a new Custom URL Rewrite.
This example will create a 301 redirect for black CD players at the URL [store-url]/black-cd-players.
Note that you have to use 301 or 302 redirects for these URL rewrites, unfortunately, as layered navigation will not work further under that URL.