Magento URL Rewrite using config.xml

Magento URL Rewrite using config.xml

This post will helpful to do the rewrite url (source to destination) from config.xml file. Normally will do the the rewriting from old url to new url  (some think like fancy url) then we will go for Magento rewrite management or .htaccess change and will do our changes, once done we will get a fancy URL for our page.

Old Url :
http://www.mywebsite.com/mymodule/mycontroller/myaction/Param/paramvalue
Ex: http://www.mywebsite.com/customproduct/index/index/productid/10

If you see the above url, seems not like a fancy url, this url is easily explain the the mangento module and controller action of this page.So we are going to change the above url to fancy kind of url

New Url Fancy:
We are going to redirect old url to new url like below
Ex: http://www.mywebsite.com/customproduct/10

Config.xml

1. Open config.xml file from customproduct module
2. add below code inside <global> tag

Code:
<global>
<rewrite>
<mycontroller_index_index>
<from><![CDATA[/customproduct\/(.*)/]]></from>
<to><![CDATA[customproduct/index/index/productid/$1]]></to>
<complete>1</complete>
</mycontroller_index_index>
</rewrite>
……
……
……
</global>

3. Cleare cache and trigger old url on browser. The page redirect to new url as like above fancy kind of url.

———————————————————————————————————————————————————————————————-

Corner of Blog:

“This world is not what we have inherited from our ancestor, It is what we have borrowed from our children “

———————————————————————————————————————————————————————————————-

Leave a Reply