I'm not sure what you approach is for getting your controllers / actions at present but I'll assume it's something simple.
A simple example.
function parseuri($uri, $basepath=null) {
$uri = str_replace(array('http://', $_SERVER['SERVER_NAME'].'/'),'',$uri);
if (null != $basepath) {
$uri = str_replace($basepath,'',$uri);
}
$parts = explode('/', $ur);
return array('controller' => $parts[0], 'action' => $parts[1]);
}
print_r(parseuri('http://foo.com/c/a'));
print_r(parseuri('http://foo.com/subdir/c/a','subdir'));
This is just an example, and not at all tested but I hope it gets the idea accross.