Magento custom extension admin urls

So you’re the kind of person that likes convention and you want your custom extension to have a URL like this.

http://www.example.com/admin/myextension/index/

It’s relatively straight-forward but not very well documented.

Simply open up your extensions config.xml located somewhere such as:

/app/code/local/Companyname/MyExtension/etc/config.xml

Inside the <config> tags add

<config>

    <admin>
        <routers>        
            <adminhtml>
                <args>
                    <modules>
                        <myextension before="Mage_Adminhtml">Companyname_MyExtension_Adminhtml</myextension>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>	
	
    
<config>    

All you need to do is ensure the following path exists

/app/code/local/Companyname/MyExtension/controllers/Adminhtml/IndexController.php

 

Gareth
Buy Me A Coffee
back arrowBack to Index