跟随 http://alanstorm.com/magento_controller_hello_world 时出错:-
未找到
在此服务器上找不到请求的 URL/magento/helloworld。
C:''wamp''www''magento''app''code''local''Bsl''Helloworld''controllers''IndexController.php
<?php
class Bsl_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Hello Index!';
}
}
C:''wamp''www''magento''app''code''local''Bsl''Helloworld''etc''config.xml
<config>
<modules>
<Bsl_Helloworld>
<version>0.1.0</version>
</Bsl_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Bsl_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
C:''wamp''www''magento''app''etc''modules''Bsl_Helloworld.xml
<config>
<modules>
<Bsl_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Bsl_Helloworld>
</modules>
</config>
你的代码都是正确的,你只是点击了错误的URL。控制器 URL 使用以下公式构建:
http://example.com/frontName/actionControllerName/actionMethod/
如果未给出操作方法,则将应用操作名称索引。因此,在您的情况下,您的URL将被 http://example.com/helloworld/index,例如您的域。由于您的操作是索引,因此您不必明确包含它是 URL。
这个网址运行良好http://magento/index.php/helloworld
通过有索引.php