Quirky Magento Rewrite Rules

Just been setting up another Magento multi-site install and thought I would share how to make sure that URLs are rewritten to their proper format.

So, you have been through the process of creating your domains, websites, stores and have set up your root categories and are just about to start adding products to each websites. Wait! Make sure you visit the URL rewrite management page first to make sure your category URLs are working correctly.

You see the problem with creating a multi-website in Magento is that you may want to duplicate categories across domains but if you don't set up a custom URL rewrite for each duplicate category then you will find that your duplicate categories end up with a -x after them. Here is an example of what I mean:

  • uk.example.com/example-category
  • de.example.com/example-category-1

You see that because there isn't a custom rewrite in place for either the UK or DE site then -1 gets added to the category name. Very annoying!

To fix this simply create a new custom rewrite for the DE store using the DE store view 'Store' parameter and another for UK store view and Magento will now happily create your rewrite on a per store view basis. Nice!

P.S. you may have to delete your old anchor rewrites first otherwise Magento will complain.