Nick Kampilis wrote:
> 
> I have had some issues with default controllers that I have not fully
> understood yet. 
> So in my index.php I just do is this:
> 
> try {
>     $controller->dispatch();
> } catch (Exception $e) {
>     // redirect to error page
>     header('Location: /index/error/');
> }
> 
Had the same problems with default routes in 0.7.0 and read your solution.
However, I didn't like generating a whole new request by performing a
redirect. So I changed it to this:

try
{
    $controller->dispatch();
}
catch (Exception $e)
{
    $request = new Zend_Controller_Request_Http();
    $request->setRequestUri('/');
    $controller->setRouter(new Zend_Controller_RewriteRouter());
    $controller->dispatch($request);
} 

I generate a new request for the desired fallback URL. Then I reset the
router of the FrontController to a clean one because the router object from
the first dispatch() call already has the non-working controller/action
combination stored inside. Finally I dispatch the new request. Hope this
helps.

-- 
View this message in context: 
http://www.nabble.com/default-controller-issues-tf3038305s16154.html#a8809256
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to