Magento 1 Admin and Frontend Route Disabling Guide

adminmagento-1routing

Is there a way to disable an admin route, well actually any route. The use case is I have an extension that comes with a frontend section and an admin section but I do not want the admin section to be used. I have disabled the admin menu items but I would like to disable the route as well so that if there are any other links or someone has it bookmarked they get a 404 or redirected to the dashboard.

I know I could setup different roles and disable for some roles but I want it to be a complete removal.

Best Answer

I don't think there is a way to do this without removing the routers tag from the config.xml or adding some observers on the predispatch event that will redirect you to a 404 page.
But I may be wrong. In case I'm wrong here is a place to start.
The routers section of the config.xml files is parsed in Mage_Core_Controller_Varien_Router_Standard::collectRoutes.
From what I saw in there, there is no check for a disabled flag or something like that.
There might be a chance if the the module does not use the admin path for backend pages.
So if the router is not declared like this:

    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Module_Name before="Mage_Adminhtml">Module_Name_Adminhtml</Module_Name>
                </modules>
            </args>
        </adminhtml>
    </routers>

but uses the other way of declaring routers:

    <routers>
        <module_name>
            <use>admin</use>
            <args>
                <module>Module_Name</module>
                <frontName>route_name</frontName>
            </args>
        </module_name>
    </routers>

You can create a module and just change the <use> tag value to something that's not admin or standard.

So your new module that depends on the original one can have the routers section like this:

<routers>
    <module_name>
        <use>go-away</use>
    </module_name>
</routers>

Why I thing it could work? because in the method mentioned above the only if with no else that could return false is if ($use == $useRouterName).
This is just an assumption. I haven't tested it. I don't have any extensions that use this type of routers for backend.