我对ZF有一个非常奇怪的问题(至少对于ZF新手来说):我无法访问现有的控制器及其操作方法。
没问题:
本地主机/
本地主机/指数
本地主机/索引/索引
localhost / index / about
但是,我设置了这样的路由:/ localhost / test,指向索引控制器和indexAction,每次访问它时都会看到404.
404不是zf的处理程序(至少它看起来像这样),我得到普通的旧apache2 notfound页面,我的apache和php版本。 在这种请求的错误日志中,我看到:“文件不存在:/ var / www / test”
Bootstrap route init:
类Bootstrap扩展了Zend_Application_Bootstrap_Bootstrap { 受保护的函数_initDoctype(){
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}
protected function _initRoute() {
$ctrl = Zend_Controller_Front::getInstance();
//$ctrl->setParam('useDefaultControllerAlways', true);
$router = $ctrl->getRouter();
//$router->removeDefaultRoutes();
$router->addRoute(
'test',
new Zend_Controller_Router_Route_Static('test',
array('controller' =>'index', 'action' => 'index',
'module' => 'default')));
}
}
据我所知,问题可能在于apache2。 .htacess是默认的,就像在docs中一样。 这是它:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
由于
答案 0 :(得分:0)
apache配置不当,重新配置解决了问题