I am currently looking at trying to generate custom urls/routing using magento, currently I have set a default route in config.xml within the local module.
<frontend>
<routers>
<portfolios>
<use>standard</use>
<args>
<module>Custom_Portfolios</module>
<frontName>portfolios</frontName>
</args>
</portfolios>
</routers>
<default>
<router>portfolios</router>
</default>
</frontend>
This currently works with the url path of /portfolios/index/action/custom-string which is the magento default route. What I am trying to achieve is to have /portfolios/custom-string.html I have attempted to use a mod_rewrite rule with no success, I have found some references in relation to utilising a custom suffix of .html which I have added to the same config.xml file.
<default><portfolios><seo><portfolios_url_suffix>.html</portfolios_url_suffix></seo></portfolios></default>
I have looked at the alan storm docs in relation to routing and found it relevent to the default routing paths only or the information is a little out-dated.
Do you know the best method to control the routing within magento with possibly an easy to follow and relevent tutorial? if so please share :D many
The easiest method (when you do not need to auto-generate many urls) is to use built-in Url Rewrites module. Go to admin backend -> Catalog -> Url Rewrite management and setup any url rewrite you like.
Code below is untested, but should work
If you don't want to define custom rewrite for each protfolio item, just follow these steps:
Write your custom router class extended from Mage_Core_Controller_Varien_Router_Standard and implement
match
method:Define your custom router in config.xml:
Enjoy your custom routing in Magento :)
The way to do this is with an URL rewrite. In fact, the suffix config you found is probably used by Mage_Catalog to create it's sets of rewrites. I'm approaching this particular feature for the first time so this snippet should be taken with a pinch of salt...
A new rewrite is needed for each possible path.
Edit; I've added a
setIdPath
because it might be necessary.