Zend索引控制器问题
我正在尝试使用 Zend 框架创建应用程序 我使用 zf 工具创建了基本的应用程序结构。
现在,当我尝试使用 http://localhost/zendApp/public/index.php 启动应用程序时 默认“欢迎使用 Zend Framework!”页面加载。
但是当我输入 http://localhost/zendApp/public/ 或 http://localhost/zendApp/public/index 时,索引控制器不会被调用,而是 相反,我收到错误消息:
*指定的控制器无效(zendApp)
array (
'controller' => 'zendApp',
'action' => 'public',
'module' => 'default',
)
如您所见,它正在尝试使用应用程序的名称启动控制器。 另外,如果我在索引控制器中创建其他操作并使用 http://localhost/zendApp/public/index/newaction 调用它 我得到同样的错误:
数组( '控制器' => 'zendApp', '行动' => '民众', '索引' => '新行动', '模块' => '默认', )
你能帮我理解为什么索引控制器没有被调用吗? 谢谢。
I am trying to create application with Zend framework so
I have created basic application structure with zf tool.
Now when I try to start application with http://localhost/zendApp/public/index.php
the default "Welcome to the Zend Framework!" page loads.
But when I type http://localhost/zendApp/public/ or http://localhost/zendApp/public/index index controller is not invoked, but
rather I get error message:
*Invalid controller specified (zendApp)
array (
'controller' => 'zendApp',
'action' => 'public',
'module' => 'default',
)
As you see, it is trying to start the controller with the name of application.
Also if I create additional actions in index controller and call it with http://localhost/zendApp/public/index/newaction
I get the same error:array (
'controller' => 'zendApp',
'action' => 'public',
'index' => 'newaction',
'module' => 'default',
)
Can you help me understand why index controller is not invoked?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的控制器的 URL 不会包含公共文件夹。例如 UserController 是
http://localhost/zendApp/user/ 不是 http://localhost/zendApp/public/user,并且您的索引控制器应该在 http://localhost/zendApp/ 或http://localhost/zendApp/index。
您的 url 重写器(例如 mod_rewrite)应该设置为将除静态文件(例如图像、css js 等)之外的所有 url 重写为 /public/index.php。请参阅 此处
您是否有此设置:
“如果您要部署到“用户”站点(例如 http://localhost/~rob),那么您需要.htaccess 文件中的 RewriteBase 行类似于: RewriteBase /~rob/zf-tutorial/public/" from 此处
The url for your controllers would not include the public folder. Eg UserController would be
http://localhost/zendApp/user/ not http://localhost/zendApp/public/user, and your index controller should work on http://localhost/zendApp/ or http://localhost/zendApp/index.
Your url rewiter (eg mod_rewrite) should be set up to rewrite all urls to /public/index.php other than static files eg images, css js etc. see here
Do you have this setup:
"If you are deploying to a "user" site (e.g. http://localhost/~rob), then you need a RewriteBase line in your .htaccess file that looks something like: RewriteBase /~rob/zf-tutorial/public/" from here