我有一个前端控制器工作。我写了一个名为AuthController.php的登录控制器。它内部配置了相应的代码。我的问题是当我去/ auth我得到一个404。这似乎是某种路由问题。Zend新手问题与控制器
我的身份验证控制器被称为AuthController.php和它的顶部是这样的:下面
class AuthController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$form = new Application_Form_Login();
$request = $this->getRequest();
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
if ($this->_process($form->getValues())) {
// We're authenticated! Redirect to the home page
$this->_helper->redirector('index', 'index');
}
}
}
$this->view->form = $form;
}
,当然也有保护功能,用于处理其他事情。在Zend中,当你创建一个新的控制器时,不仅仅它的存在(就像在CodeIgniter中那样)意味着它应该可用?或者我必须将其添加到某个路由表中?
编辑:这是我的Apache虚拟主机配置:
<VirtualHost *:80>
ServerName new.mydomain.com
DocumentRoot /www/htdocs/zend/public
<Directory /www/htdocs/zend/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
有'[/ module]/controller/action'的默认路由如果你没有指定动作,那么它会尝试执行'indexAction'。很难告诉你为什么它不能通过提供的代码工作。如果404不是一个例外,而是服务器404的响应,那么你的'mod_rewrite' /'htaccess'没有正确配置。 –
我检查了.htaccess,它看起来不错。也许apache配置不正确。这不在我的服务器上,所以我会检查。谢谢! –
你使用的是Apache吗?你应该看看你的虚拟主机配置。如果设置不正确,您将只会显示默认索引页面,因为Apache不会将路由传递给Zend。如果可以,请共享虚拟主机配置。 –