I am having some trouble creating dynamic subdomains. The idea is to route the following URL:
asdf.budget.com to
www.budget.com/test/index/asdfI have setup a Controller Plugin:
<?php
class Rob_Controller_Plugin_Route extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
//http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.hostname
//http://www.noginn.com/2008/09/03/using-subdomains-as-account-keys/
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->removeDefaultRoutes();
$pathRoute = new Zend_Controller_Router_Route(
':controller/:action/*',
array(
'controller' => 'index',
'action' => 'index'
)
);
$adminRoute = new Zend_Controller_Router_Route_Hostname(
':test.budget.com',
array(
'controller' => 'test',
'action' => 'index'
)
);
$router->addRoute('test', $adminRoute->chain($pathRoute));
$defaultRoute = new Zend_Controller_Router_Route_Hostname(
'www.budget.com',
array(
'module' => 'default',
)
);
$router->addRoute('default', $defaultRoute->chain($pathRoute));
}
}
And connect it in my applications.ini file:
resources.frontController.plugins.Route = "Rob_Controller_Plugin_Route";
However, it's not routing to the test controller and index action when I enter in a subdomain. Anyone see what's wrong here? Any help is greatly appreciated.