【问题标题】:magento 404 not found找不到magento 404
【发布时间】:2023-03-31 23:44:01
【问题描述】:

我是 magento 的新手。我放松了它的教程并创建了我的第一个模块。 但它返回 404 未找到:

config.xml 文件如下:

<?xml version='1.0'?>
<config>    
    <modules>
        <Magentotutorial_Helloworld>
            <version>0.1.0</version>
        </Magentotutorial_Helloworld>
    </modules>

</config>

Magento_Helloworld.xml 是:

<config>
    <modules>
        <Magentotutorial_Helloworld>
            <active>true</active>
            <codePool>local</codePool>
        </Magentotutorial_Helloworld>
    </modules>
    <frontend>
        <routers>
            <helloworld>
                <use>standard</use>
                <args>
                    <module>Magentotutorial_Helloworld</module>
                    <frontName>helloworld</frontName>
                </args>
            </helloworld>
        </routers>  
    </frontend>
</config>

控制器是:

class Magentotutorial_Helloworld_IndexController extends Mage_Core_Controller_Front_Action {

    public function indexAction() {
        die( 'Hello Index!');
    }

}

现在我试试

http://127.0.0.1/magento/index.php/helloworld/index/index

然后查看 404 页面!问题出在哪里?

我从管理员那里清除了缓存!

【问题讨论】:

  • 你的模块是否在system-&gt;configuration tab advanced中列出。

标签: php magento magento-1.9


【解决方案1】:

您的 xml 文件的内容应如下所示: 'app/etc/modules/Magentotutorial_Helloworld.xml':

<?xml version="1.0"?>
<config>
    <modules>
        <Magentotutorial_Helloworld>
            <active>true</active>
            <codePool>local</codePool>
        </Magentotutorial_Helloworld>
    </modules>
</config>

'app/code/local/Magentotutorial/Helloworld/etc/config.xml':

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

附:控制器应该在 'app/code/local/Magentotutorial/Helloworld/controllers/' 目录中

【讨论】:

  • 不工作!!它的控制器在“控制器”目录中
  • 你检查了日志(php错误日志,异常.log,system.log),也许你在其他地方有错误?
  • 哎呀!我是初学者!我在另一个文件夹中创建了“本地”目录!!
【解决方案2】:
$ a2enmod rewrite
$ service apache2 restart

【讨论】:

  • 请多解释一下您的解决方案,以便未来的搜索者可以将其应用于他们的情况。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-16
  • 2014-09-02
  • 2015-09-13
  • 2015-11-01
  • 2013-06-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多