【发布时间】:2009-08-16 21:37:41
【问题描述】:
我遇到了一个非常奇怪的 ZF 问题(至少对于 ZF 新手而言):我无法访问我现有的控制器及其操作方法。
没有问题:
本地主机/
本地主机/索引
本地主机/索引/索引
本地主机/索引/关于
但是,我设置了这样的路由:/localhost/test,指向索引控制器和 indexAction,每次访问时都会看到 404。
404 不是 zf 的处理程序(至少看起来像这样),我在那里得到了带有我的 apache 和 php 版本的普通旧 apache2 notfound 页面。 在此类请求的错误日志中,我看到:“文件不存在:/var/www/test”
引导路由初始化:
类 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 是默认的,就像在文档中一样。 就是这样:
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]
谢谢
【问题讨论】:
标签: apache zend-framework rewrite routes