views:

369

answers:

1

Hi All,

I've spent many hours trying to get this to work. And I'm getting quite desperate. Would be great if someone out there could help me out :)

Currently using Zend Framework 1.9.5, though I have been struggling to get this to work for many versions now.

What I want to do is provide my own routes through an XML config, and make sure that everything that is not defined in my config will end up on my errorController. (preferably in a way so I can em apart from EXCEPTION_NO_CONTROLLER and EXCEPTION_NO_ACTION)

I figured that this means I have to get rid of default /:module/:controller/:action and /:controller/:action routes.

So when I tell the router to removeDefaultRoutes(), it won't match these default routes anymore. But now the router is now routing every unrouted route to the defaultcontroller::defaultaction (What the ??)

$front->getRouter()->removeDefaultRoutes();

So, anyone know how to make the frontcontroller (or a part of it) throw an exception when an URI can not be routed?

Reason I want to do this is to prevent duplicate content, and have better 404 pages (in this case, no controller / no action errors are actually application errors instead of not-found)

+1  A: 

did you try adding a new route like

$route = new Zend_Controller_Router_Route('*', array('controller'=>'error', 'module'=>'default', 'action'=>'error');


$router->addRoute('default', $route);

You need to add this route first as it needs to be the last processed.

prodigitalson
Okay, this is what I've done. It works, because on that action, I throw an exception that indicates 404.It's still a workaround, but thanks for the help mate
Maurice