-- naioshi cozmicboy <[EMAIL PROTECTED]> wrote
(on Thursday, 24 May 2007, 05:38 AM +0200):
> I would like to set my router to use IndexController in case the
> controller name is invalid.
>
> e.g.
>
> 1. http://example.net/library/index/edit/id/12 (ok)
> 2. http://example.net/library/edit/id/12 (error: invalid controller)
>
> module=library
> controller=index (controller edit does not exist)
> action=edit
>
> Is there a way to set the router to work in case 2. the same way as it
> does in case 1.?
> Any help appreciated.
You should probably create new routes for your library module. The
easiest way would be something like this:
$route = new Zend_Controller_Router_Route(
'library/:action/*',
array('module' => 'library', 'controller' => 'index', 'action' =>
'index')
);
$router->addRoute('library', $route);
Of course, this means that /library/index/edit/id/12 would no longer
work. If you expect both to work, you should probably rethink your
routing, as this will mean 2 different paths to the same resource, which
is not usually a good strategy (particularly for SEO).
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/