Magento URL Request Routing

Magento is a typical PHP Model View Architecture (MVC) system which routes its URLs in ways not particularly different from other PHP MVC Frameworks like codeigniter, symphony etc. But the difference it has with other MVC architecture is that most of its routing directives or configurations are XML based i.e. found in one XML file or the other.

For example,, tells Magento to use the checkout module found in app/code/Mage/, use the cart controller (i.e. CartController.php) in app/code/Mage/Checkout/controller/ and run the index action method in the CartController.php, when the last “index” is omitted Magento still defaults to run the index action method, and every other value in the url after the first three url steps, Magento treats them as PHP GET parameters i.e. would make $_GET[‘store’]=1

It is this action method that searches through the magneto xml configuration file using x-path to obtain information regarding this request e.g. the indexAction method found in app/code/Mage/Checkout/controller/CartController.php uses Mage::getStoreConfig(‘sales/minimum_order/description’) to get the value of the description node in sales module, the minimum_order node and description child node, which can be found in system.xml in the Sales/etc/ folder.

Its is worthwhile also knowing that Magento uses Apache’s URL rewrite engine (mod_rewrite) to make its URLs SEO friendly i.e. could be routed to which can be regarded as an alias for to make Google happy and improve the sites SEO.

This basically describes how Magento decides what to do when accessed by a particular URL.

Tags: seodevelopmentphpmagentoapachemod_rewriteurlmvc