Phalcon's router doesn't match subdomains. You have to match $_SERVER['SERVER_NAME'] with a regular expression to create corresponding routers.
<?php
$di = new \Phalcon\Di\FactoryDefault();
$di->setShared('router', function() {
// Match subdomain with regular expression
if(preg_match("/^(\\w+)\\.site\\.com$/", $_SERVER['SERVER_NAME'], $matches) === 1) {
$subdomain = $matches[1];
}
// Create a router without default routes
$router = new \Phalcon\Mvc\Router(false);
if (isset($subdomain)) {
// Create routes for subdomains
$router->add('/category', array(
'controller' => 'category',
'action' => 'categorySearch'
));
} else {
// Create routes for main domain
}
return $router;
});
// Retrieve corresponding router at runtime
$di->getShared('router')->handle();