You can only do that with a front controller. You route every request to it (that matches your URI format), and have it check the parameters.
If they match, you can use an HMVC call to a second controller to deal with the information, and if they don't match, do an HMVC call using the 'do not route' flag to see if there is a controller/method combination that matches the URI.
The router has no mechanism to do a parameter lookup before making a routing descision. It's a feature we're thinking about for a future version.
I have a temporary solution for that which is used the _404_ route.
action_404 will check whether user has logged in and then try to search the user id from the database.
I'm doing something similar to facebook e.g. FB user, FB page, FB group and some other feature using the same user id index. If I use a front controller, it will somehow increase the delay when request a static page.
But I'm doing some other way. I've changed to use an object instead of a controller. So I created a class Front ( classes/front.php ). The route then use a closure:
"([0123456789abcdef]{20})(/:any)?" => function()
{
if (Front::check())
{
Front::forward();
}
else
{
throw new HttpNotFoundException();
}
}
The only problem is, if the user id can be anything, like facebook, twitter, github, etc, user can use any name they want except system reserved keywords, then the route will have to check from the other way.
Route will have to check the user name is not in the reserved keywords list:
So, I think that route should able to continue find the correct controller before throw an exception.
Let say there is a controller user with action_home but not listed in routes.php because it will be able to access automatically. But Route will pass it to the Closure that check for user id. It will fail. So if somehow the Closure can tell the Route continue to find the correct controller, then it will work.