Magento : Front controller reached 100 router match iterations

Magento Ecommerce In Magento basic urls look like this ‘{name-of-the-module}/{controller}/{action}’ , If the url looks like this ‘{name-of-the-module}/{controller}/’ it’s equivalent to ‘{name-of-the-module}/{controller}/index’ , If the url looks like this ‘{name-of-the-module}/’ it’s equivalent to ‘{name-of-the-module}/index/index’.

For categories and products there is a routing table (core_url_rewrite) in which are saved different rewrite rules in order to have an url like this: /product.html instead of catalog/product/view/id/7869.

This is what happens, internally: you call an url ‘demo-url.html’. Magento looks in the rewrites table for a record with the ‘request_path’ equal to ‘demo-url.html’ in the current store view.  If it’s not found then it searches for a cms page with this identifier and active on the current store view.
If that is not found Magento tries to match it to an url of this form ‘{name-of-the-module}/{controller}/{action}’
if this doesn’t work then you get an error If it finds such a record then if the ‘options’ value is ‘RP’, this means it’s a redirect and you get redirected to the url listed in the ‘target_path’ field else it starts the process all over again with the url from ‘target_path’.
There is a limit of 100 tries. I mean if after 100 tries Magento still finds a record matching the ‘request_path’ you get an internal error ‘Front controller reached 100 router match iterations’

Now for the other part of the url rewrites: how are they saved?

Each time you save a product/category (actually when you save the url key attribute of a product/category) an url rewrite is created. For more details on who this works see Mage_Catalog_Model_Product_Attribute_Backend_Urlkey::beforeSave(); – here the url key is prepared (stripped of illegal characters) The actual saving of the rewrite is done here: Mage_Catalog_Model_Url::refreshProductRewrite() or refreshCategoryRewrite()
What these methods do is to insert records in the core_url_rewrite table with the product/category url_key as ‘request_path’ and ‘catalog/product/view/id/7869’ or ‘catalog/category/view/id/9’ in order to be matched later by the above algorithm.



Magento URL Rewrites in a Collection

To Enable Url rewrites while using a Magento collection just add this to the end of collection:


which adds URL rewrites to collection flag