Search code examples
phpmagentomagento-1.7magento-1.9

Magento 1.9: is there a way to rename a route without renaming the entire module?


I am working on a project where a module named Namespace_Ticket was adapted to work as an invoices list.

However, the URL to access this module is like this:

http://dev.local/index.php/tickets/index/index/ticket_id/9568/

I would like to be able to remove the word "tickets" from the URL and replace it with "invoice". I want my URL to look like this:

http://dev.local/index.php/invoices/index/index/invoice_id/9568/

Is there a way I can do it without having to rename the entire module?

Thank you.


Solution

  • Router name is defined in module's etc/config.xml file, you will find a code similar to below

    <routers>
        <modulename> <!--or this may be ticket -->
            <use>standard</use>
            <args>
               <module>Namespace_Ticket</module>
               <frontName>tickets</frontName> <!-- You have to change this value to change the router -->
            </args>
        </modulename>
    </routers>
    

    Router need to be defined separately for both admin and frontend, you can found both under <frontend> and <admin> nodes.

    After changing router frontname, make sure that you have to change router wherever the url is used throughout the site.