Magento Controller Works Windows, not Linux

2019-06-24 19:34发布

问题:

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.

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.

The controller file is /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

The extract from my XML config file is here:

<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.

<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!

<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

回答1:

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:

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



回答3:

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:

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

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