I would like to call three urls that show me three views from one module with three methods and three templates. Exemple Saying that I have a module called promo and controller is IndexController.php and in the controller three methods: method1, method2, method3.

Url 1 : www.exemple.com/promo/index/method1

Url 2 : www.exemple.com/promo/index/method2

Url 3 : www.exemple.com/promo/index/method3

It is possible to replace the urls to :

Url 1 : www.exemple.com/promo

Url 2 : www.exemple.com/promo2

Url 3 : www.exemple.com/promo3

Which my question and my idea is to call directly the frontname in the URL and this allows me to not create three modules for only three views.

1 Answer 1


It is possible, to have different front names mapping to the same module.

Create multiple nodes below <routers> in your modules config.xml. They will have the same value in <module> but different values in <frontName>:


(your_module_1 and your_module_2 is arbitrary, each element name just has to be unique).

But this results in:

/promo   => your_module/index/index
/promo2  => your_module/index/index

Each front name maps to the same module, so these URLs both result in the same controller action to be called.

So to achieve what you want, you don't need different front names, but instead a custom router.

Here's a tutorial for writing a custom router: http://inchoo.net/magento/custom-router-in-magento/

The router will check if the URL starts with "promo", and if it is the case, set the appropiate controller and action in the request object.

  • Thanks @Fabian but the tuto of inchoo is really complicated and long :/
    – PЯINCƎ
    Feb 7, 2017 at 23:22
  • 1
    If "long" is a problem for you, I can't help you. There are numerous other tutorials out there, maybe you find a shorter one. Is there any particular part that you do not understand? Feb 8, 2017 at 7:09
  • What do you think about this: @Fabian Schmengler public function indexAction(){ $currentUrl = Mage::helper('core/url')->getCurrentUrl(); $url1 = Mage::getBaseUrl().'promo'; $url2 = Mage::getBaseUrl().'promo2'; if ($currentUrl == $url1){ public function promoAction(){ //... } if ($currentUrl == $url2){ public function promooAction(){ ` //...` } ` }` }
    – PЯINCƎ
    Feb 8, 2017 at 7:29
  • A bit hacky and not the standard way but it would work. A possible problem is if your URLs are accessible with HTTP and HTTPS, or if there might be additional parameters (for example for tracking campaigns). You'll want to take this into account at least and only compare a part of the current URL. You can use parse_url() for this purpose Feb 8, 2017 at 7:37
  • Ok thanks @Fabian i'll test this and i'll come back to you
    – PЯINCƎ
    Feb 8, 2017 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.