尽管适用于索引页,但在 zend 框架中找不到 url [英] url not found in zend framework though working for index page

查看:31
本文介绍了尽管适用于索引页,但在 zend 框架中找不到 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 zend 框架开发网站,所以我创建了一个 index.php 文件,我所有的请求都在其中发送并创建了两个控制器,一个是 IndexController,另一个是 TestController

i am trying to develop website using zend framework so i had created one index.php file where all my requests goes and c.reated two controller one is IndexController and other is TestController

Class IndexController extends Zend_Controller_Action{
    public function indexAction(){
        echo "Index Index Jamla";
    }
    public function displayAction(){
        echo "Index Display Jamla";
    }
}

现在当我访问 url http://test/它正确调用 IndexController 及其 IndexAction 函数但是当我访问 url http://test/index/index它显示消息 url/index/index was not found on this server 正如我访问 http://test/test/时一样索引

now when i access the url http://test/ it correctly calls IndexController and its IndexAction function but when i access the url http://test/index/index it displays the message url /index/index was not found on this server same it does when i access http://test/test/index

虽然 http://test/ 等价于 http://test/index/index

推荐答案

Zend Framework 的重写规则不起作用.

The rewrite rules for Zend Framework are not working.

http://test 工作是因为 Apache 默认运行 index.php,它将运行您的应用程序.路由器将看不到 URL 参数,因此它路由到索引控制器索引操作.当您尝试访问其他任何内容时,Apache 正在处理请求并且不会将其重写到 index.php,因此您会收到 404 not found.

http://test works because Apache is defaulting to run index.php which will run your application. The router will see no URL parameters so it routes to index controller index action. When you attempt to access anything else, Apache is handling the request and is not rewriting it to index.php so you are getting a 404 not found.

确保包含重写规则的 .htaccess 位于您的公用文件夹中.还要检查 Apache 是否允许通过在 httpd.conf 和/或 httpd-vhosts.conf 中设置 AllowOverride All 来处理文档根目录的 .htaccess 文件.

Make sure the .htaccess containing the rewrite rules is in your public folder. Also check that Apache allows processing of .htaccess files for your document root by setting AllowOverride All in httpd.conf and/or httpd-vhosts.conf.

这篇关于尽管适用于索引页,但在 zend 框架中找不到 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆