早上好!我正在尝试创建一个 Magento 模块,但我在模块的 config.xml 中定义的路由导致了 404 页面。

我知道这个问题已经出现了无数次,我花了一整晚的时间阅读我能找到的关于这个主题的每一个 SO 回复。

这是我所做的:

  • 清除了 var/cache & var/session 文件夹
  • Ran compiler.php -- clear, compiler.php -- disable, compiler.php -- compile
  • 清除并刷新管理面板中的缓存和缓存存储,从后端和命令行重新索引
  • 创建了一个用于测试的新包/模块,与我之前使用的完全不同。它显示在系统>>配置>>高级中。
  • 验证 Magento 没有将商店代码附加到 URL
  • 将我的代码一直简化到我的 Controller 文件夹中 IndexController.php 的 indexAction() 函数中的单个 echo 语句。
  • 尝试导航到 mydomain.com/customroute 和 mydomain.com/index.php/customroute 和 mydomain.com/customroute/index/index 和 mydomain.com/index.php/index,以及所有可能的变体。
  • 多次重复步骤 1-8。 xD

  • 下面是一些截图供引用。预先感谢您 - 如果有人有任何想法如何克服这一点,那将是一个救命稻草。谢谢!!
  • http://i.imgur.com/PP0Fuuu.png "config.xml"
  • http://i.imgur.com/YjMxate.png "IndexController.php"

  • 编辑:

    这是 app/etc/modules/Wolverine_Taurine.xml 中的代码:
    <?xml version="1.0"?>
    <config>
        <modules>
            <Wolverine_Taurine>
                <active>true</active>
                <codePool>local</codePool>
            </Wolverine_Taurine>
        </modules>
    </config>
    

    金刚狼/牛磺酸/etc/config.xml:
    <?xml version="1.0"?>
     <config>
        <modules>
            <Wolverine_Taurine>
                <version>1.0</version>
            </Wolverine_Taurine>
        </modules>
        <frontend>
            <routers>
                <wolverine_taurine>
                    <use>standard</use>
                    <args>
                        <module>Wolverine_Taurine</module>
                        <frontName>taurine</frontName>
                    </args>
                </wolverine_taurine>
            </routers>
        </frontend>
     </config>
    

    金刚狼/牛磺酸/ Controller /IndexController.php:
    <?php
    class Wolverine_Taurine_IndexController extends Mage_Core_Controller_Front_Action
    {
        public function indexAction()
        {
            echo "I look incredible.";
        }
    }
    

    最佳答案

    我已经使用了你的模块,它非常适合我。如果您使用的是 linux 平台,则对所有文件和文件夹给予适当的权限。我认为这是由于文件/文件夹权限而发生的。将 Magento 基本目录中所有文件的 Linux 权限更改为所有者用户(您)可读和可写。将文件权限设置为 664,文件夹权限设置为 775。 775 for files 也可以。为 media 和 var 设置 777,只需要 2 个文件夹可供所有人写入。

    关于php - Magento 自定义路由/ Controller 转到 404,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17511503/

    10-14 22:57
    查看更多