Magento Controller适用于Windows,而不适用于Linux

时间:2021-04-02 07:06:08

I have created a module that works on my Windows XAMPP installation. Testing on Linux, however, does not seem to work correctly. More specifically, my controller does not seem to load.

我创建了一个适用于我的Windows XAMPP安装的模块。但是,在Linux上进行测试似乎无法正常工作。更具体地说,我的控制器似乎没有加载。

When visiting the url www.mysite.com/modulename/standard/ I am getting a 404 error. I am expecting to get a message outputting the die('here') that precedes the class definition in the controller.

访问网址www.mysite.com/modulename/standard/时出现404错误。我希望在控制器中的类定义之前输出消息('here')。

The controller file is /app/code/local/Namespace/Modulename/controllers/StandardController.php.

控制器文件是/app/code/local/Namespace/Modulename/controllers/StandardController.php。

The class is defined inside this file like so:

该类在此文件中定义如下:

class Namespace_Modulename_StandardController extends Mage_Core_Controller_Front_Action

class Namespace_Modulename_StandardController扩展Mage_Core_Controller_Front_Action

The extract from my XML config file is here:

我的XML配置文件的摘录如下:

<frontend>      
    <routers>
        <modulename>
            <use>standard</use>
            <args>
                <module>Namespace_Modulename</module>
                <frontName>modulename</frontName>
            </args>
        </modulename>
    </routers>
    <!-- other blocks here -->
</frontend>

My initial thought was that it was a case sensitivity issue that I hadn't noticed by developing on Windows. The XML fragment was previously as follows, which also did not work. Please also note that I have tried visiting www.mysite.com/Modulename/standard and www.mysite.com/modulename/standard for both XML versions, with a 404 error every time.

我最初的想法是,这是一个区分大小写的问题,我没有注意到在Windows上开发。以前的XML片段如下,但也没有用。另请注意,我已尝试访问www.mysite.com/Modulename/standard和www.mysite.com/modulename/standard以获取两个XML版本,每次都会出现404错误。

<Modulename>
    <use>standard</use>
    <args>
        <module>Namespace_Modulename</module>
        <frontName>Modulename</frontName>
    </args>
</Modulename>

Does anybody know what could be the problem?

有谁知道可能是什么问题?

Thank you.

Edit

As requested, here is the module's config file. This all seems to be correct - the module is displayed in the Admin/Developer page and the module configuration screen (generated in system.xml) appears in the backend. Moreover, parts of the module (and seemingly the controller) are working in the frontend!

根据要求,这是模块的配置文件。这一切似乎都是正确的 - 模块显示在Admin / Developer页面中,模块配置屏幕(在system.xml中生成)出现在后端。此外,模块的一部分(以及看似控制器)正在前端工作!

<config>
<modules>
    <Namespace_Modulename>
        <active>true</active>
        <codePool>local</codePool>
    </Namespace_Modulename>
</modules>
</config>

Edit 2

Some versions may prove useful. PHP 5.3 Magento 1.5.1.0

某些版本可能有用。 PHP 5.3 Magento 1.5.1.0

3 个解决方案

#1


0  

Try this code:

试试这段代码:

<frontend>      
    <routers>
        <namespace_modulename>
            <use>standard</use>
            <args>
                <module>Namespace_Modulename</module>
                <frontName>modulename</frontName>
            </args>
        </namespace_modulename>
    </routers>
    <!-- other blocks here -->
</frontend>

#2


0  

Is your controller actually named StandardController.php? On case-sensitive file systems part before "Controller" should start from uppercase letter and all other letters should be lowercased

你的控制器实际命名为StandardController.php吗?在区分大小写的文件系统部分之前,“Controller”应该从大写字母开始,所有其他字母应该是小写的

#3


0  

I can't believe it!

我简直不敢相信!

My development box was updated without my knowledge, it would seem, and in the process my Apache configuration was changed! I finally realized that I wasn't receiving Magento's usual 404 error page and only a plain, ugly 404 page, and checked my Apache error logs which said that the file /Modulename/standard didn't exist. Updating my Apache configuration to add the following fixed the problem:

我的开发盒在我不知情的情况下进行了更新,看起来似乎已经在我的Apache配置发生了变化!我终于意识到我没有收到Magento通常的404错误页面,只有一个简单,丑陋的404页面,并检查了我的Apache错误日志,其中说文件/ Modulename / standard不存在。更新我的Apache配置以添加以下内容解决了以下问题:

<Directory "mymagentodirectory">
AllowOverride All
</Directory>

I can't believe that. Thanks to all who took the time to read and reply! :)

我不敢相信。感谢所有花时间阅读和回复的人! :)

#1


0  

Try this code:

试试这段代码:

<frontend>      
    <routers>
        <namespace_modulename>
            <use>standard</use>
            <args>
                <module>Namespace_Modulename</module>
                <frontName>modulename</frontName>
            </args>
        </namespace_modulename>
    </routers>
    <!-- other blocks here -->
</frontend>

#2


0  

Is your controller actually named StandardController.php? On case-sensitive file systems part before "Controller" should start from uppercase letter and all other letters should be lowercased

你的控制器实际命名为StandardController.php吗?在区分大小写的文件系统部分之前,“Controller”应该从大写字母开始,所有其他字母应该是小写的

#3


0  

I can't believe it!

我简直不敢相信!

My development box was updated without my knowledge, it would seem, and in the process my Apache configuration was changed! I finally realized that I wasn't receiving Magento's usual 404 error page and only a plain, ugly 404 page, and checked my Apache error logs which said that the file /Modulename/standard didn't exist. Updating my Apache configuration to add the following fixed the problem:

我的开发盒在我不知情的情况下进行了更新,看起来似乎已经在我的Apache配置发生了变化!我终于意识到我没有收到Magento通常的404错误页面,只有一个简单,丑陋的404页面,并检查了我的Apache错误日志,其中说文件/ Modulename / standard不存在。更新我的Apache配置以添加以下内容解决了以下问题:

<Directory "mymagentodirectory">
AllowOverride All
</Directory>

I can't believe that. Thanks to all who took the time to read and reply! :)

我不敢相信。感谢所有花时间阅读和回复的人! :)