I'm trying to "shorten" my URLs, for example from:
http://mydomain.com/controller/method/something-here
into
http://mydomain.com/something-here
by adding to routes.php
:
$route['(.*)'] = 'router/resolve/$1';
and creating a Router
class, whose resolve()
method determines whether something-here
matches a row in one of my database tables (entities). If so, I want to load the entry by calling the appropriate controller::method.
For example, if something-here
is a type of book
, I'd like Router::resolve()
to call Book::view($id)
.
However, I realize it's not possible for a controller to call the method of another controller. (Is it?)
I also cannot use redirect("book/view/$id")
because $route['(.*)']
will call Router::resolve()
on book
(the first segment).
Any suggestions on how to achieve my goal?