url not found in zend framework though working for

2019-07-31 04:14发布

问题:

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";
    }
}

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

though http://test/ is equivalent to http://test/index/index

回答1:

The rewrite rules for Zend Framework are not working.

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.

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.



回答2:

Make sure that you have set AllowOverride to All in your Apache configuration and have enabled the mod_rewrite extension



回答3:

Silly but can you recheck again either index.phtml file exists under views/scripts/index/