我剛開始用zend framework 1.9.1進行冒險,但是我遇到了一些問題。我想刪除默認路由,從而避免顯示不同的URL相同的內容 - 才達到它,我在bootstraper寫自定義函數ZF路由問題
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initMyRouter()
{
$this->bootstrap('router')
->getContainer()
->frontcontroller
->getRouter()
->removeDefaultRoutes();
}
}
但在此之後,一個問題出現 - 每一個無效的URL達到默認的控制器,而不是錯誤控制器。爲了解決這個問題,我把 resources.frontController.defaultcontrollername =「錯誤」 resources.frontController.defaultaction =「扔」在的application.ini 和
public function throwAction()
{
throw new Zend_Controller_Dispatcher_Exception;
}
在ErrorController要解決這一點,但我的問題是.. 。 難道我做錯了什麼?
第二個問題是我只需要生成絕對URL,因此我在application.ini中添加了resources.frontController.baseurl =「http://mydomain.com/」,但之後每個URL指向默認控制器。如何解決它?
第三個(也是最後一個)是......如何在我的操作中調用Zend_Controller_Action_Helper_Url :: url?我試過類似$ this - > _ helper-> url(array(),'frontpage'),但它調用Zend_Controller_Action_Helper_Url :: direct