I found a problem with Magento's routing logic, and I would like to know if anyone can confirm this.
Magento installs the admin, standard, then default routers and processes them one at a time. Magento obtains the current module name based on the URL (see Mage_Core_Controller_Varien_Router_Standard::match())
, and then checks whether the module should be processed by this router based on the frontName match in the Magento configuration. If a match is found, it directs it. If not, it will continue to the next router.
Configuration Excerpt:
<admin>
<routers>
<myroute>
<use> admin </use>
<args>
<module> MyNamespace_MyModule </module>
<frontName> myroute </frontName>
</args>
</myroute>
</routers>
</admin>
<frontend>
<routers>
<myroute>
<use> admin </use>
<args>
<module> MyNamespace_MyModule </module>
<frontName> myroute </frontName>
</args>
</myroute>
</routers>
</frontend>
This means that if you use the same name for your external router as an administrator, the administrator router will always be negotiated first, even on the front-end pages. Now your front-end page will be routed as if it had an admin base_url
using admin base_url
, which may be different from your store URL, resulting in a broken redirect.
Note that this problem does not occur in instances of Magento, where the base URL of the administrator matches the base URL.
Can anyone confirm that my assessment of the router logic here is correct?
source share