0

I want to create new route, ex:brand

I tried to access www.myPage.com/brand and www.myPage.com/index.php/brand

But it just shows 404 page not found after I create this scripts bellow.

This is my IndexController.php scripts :

<?php

class MyWeb_Brand_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo 'Hello developer...';
    }

    public function sayHelloAction()
    {
        echo 'Hello one more time...';
    }
}
?>

My config.xml scripts :

<?xml version="1.0"?>

<config>
    <modules>
        <MyWeb_Brand>
            <version>0.1.0</version>
        </MyWeb_Brand>
    </modules>    
    <frontend>
        <routers>
            <MyWeb_Brand_Route>
                <use>standard</use>
                <args>
                    <module>MyWeb_Brand</module>
                    <frontName>brand</frontName>
                </args>
            </MyWeb_Brand_Route>
        </routers>
    </frontend>    
</config>

And this my app/etc/modules/myWeb_Brand.xml file:

<?xml version="1.0"?>

<config>
    <modules>
        <MyWeb_Brand>
            <active>true</active>
            <codePool>local</codePool>
        </MyWeb_Brand>
    </modules>
</config>
1

Location of activation file is wrong here. It should be app\etc\modules\MyWeb_Brand.xml instead of app/etc/module/myPage_Brand.

Also please note Raphael's answer too. They are actually coding and concept standards, not a complete requirement.

Also make sure locations of following files are correct.

  • Config File : app\code\local\MyWeb\Brand\etc\config.xml
  • Controller : app\code\local\MyWeb\Brand\controllers\IndexController.php

With these, your are good to go, I guess.

Please make sure, you remove all your caches after these changes applied.

  • I'm sorry my question has some typos. I've edited my question. please check again – syahidah humairoh Feb 9 '17 at 9:03
  • please see edit in my answer. – Rajeev K Tomy Feb 9 '17 at 9:04
2

Change your config.xml file with below code

<?xml version="1.0"?>
<config>
    <modules>
        <MyWeb_Brand>
            <version>0.1.0</version>
        </MyWeb_Brand>
    </modules>    
    <frontend>
        <routers>
            <brand>
                <use>standard</use>
                <args>
                    <module>MyWeb_Brand</module>
                    <frontName>brand</frontName>
                </args>
            </brand>
        </routers>
    </frontend>    
</config>

In above file have one mistake you wrote Nekindo_Brand but module name is MyWeb_Brand

Your module config filename is MyWeb_Brand.xml at app/etc/modules/MyWeb_Brand.xml instead of myPage_Brand.xml

1

I reckon you need to update the router declaration part like this:

<frontend>
    <routers>
        <brand>
            <use>standard</use>
            <args>
                <module>MyWeb_Brand</module>
                <frontName>brand</frontName>
            </args>
        </brand>
    </routers>
</frontend>    

On top of that, the file under app/etc/modules should be renamed MyWeb_Brand.xml

  • I'm sorry my question has some typos. I've edited my question. please check again – syahidah humairoh Feb 9 '17 at 9:02
  • @syahidahhumairoh even after editing your question, my answer still applies to your question. Please apply my changes – Raphael at Digital Pianism Feb 9 '17 at 9:09
0

Change your config XML router like this:-

<frontend>
    <routers>
        <brand>
            ......
        </brand>
    </routers>
</frontend>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.