ZF 有一个非常奇怪的问题(至少对于 ZF 新手而言):我无法访问我现有的控制器及其操作方法。
没有问题: localhost/
localhost/index
localhost/index/index
localhost/index/about
但是,我设置了这样的路由:/localhost/test,指向索引控制器和 indexAction,每次访问它时都会看到 404。
404 不是 zf 的处理程序(至少看起来像这样),我在那里得到了带有我的 apache 和 php 版本的普通旧 apache2 notfound 页面。在此类请求的错误日志中,我看到:“文件不存在:/var/www/test”
引导路由初始化:
类 Bootstrap 扩展 Zend_Application_Bootstrap_Bootstrap { protected function _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 是默认的,就像在文档中一样。就这个:
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]
谢谢