Custom frontend controller returns 404
-
11-10-2020 - |
Question
I disabled Magento cache before I began to work on this.
I can see my module is visible in "System/Configuration/Advance/Disable Modules Output" listing.
But if I call this module as http://localhost/mag/index.php/mymodule/index I get 404 Not Found
error.
Can you please point out where I'm doing wrong here? I need to understand why.
Thanks in advance
Here are my codes
app/code/local/Mycompany/mymodule/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mycompany_Mymodule>
<version>0.1.0</version>
</Mycompany_Mymodule>
</modules>
<frontend>
<routers>
<mymodule>
<use>standard</use>
<args>
<module>Mycompnay_Mymodule</module>
<frontName>mymodule</frontName>
</args>
</mymodule>
</routers>
</frontend>
</config>
app/etc/modules/Mycompany_Mymodule.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mycompany_Mymodule>
<active>true</active>
<codepool>local</codepool>
</Mycompany_Mymodule>
</modules>
</config>
app/code/local/Mycompany/Mymodule/controllers/IndexController.php
class Mycompany_Mymodule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'hello World!';
}
}
Solution
You have a typo mistake in app/code/local/Mycompany/mymodule/etc/config.xml
You have used Mycompnay_Mymodule
inplace of Mycompany_Mymodule
at line
<module>Mycompnay_Mymodule</module>
There is one more change you need to do to make it work. Open your app/etc/modules/Mycompany_Mymodule.xml change
<codepool>local</codepool>
To
<codePool>local</codePool>
With a capital P
It should work for you.
OTHER TIPS
Problem with your router name <mymoduleroutename>
It's should be <mymodule>
Update this below code in your file path:-
app/code/local/Mycompany/Mymodule/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mycompany_Mymodule>
<version>0.1.0</version>
</Mycompany_Mymodule>
</modules>
<frontend>
<routers>
<mymodule>
<use>standard</use>
<args>
<module>Mycompnay_Mymodule</module>
<frontName>mymodule</frontName>
</args>
</mymodule>
</routers>
</frontend>
</config>
I Hope It's helpful for you.