Author Topic: Dynamic Subdomains & Zend_Controller_Router_Route_Hostname?  (Read 1901 times)

0 Members and 1 Guest are viewing this topic.

Offline shlumphTopic starter

  • Enthusiast
  • Posts: 451
  • Gender: Male
    • View Profile
    • My Site
Dynamic Subdomains & Zend_Controller_Router_Route_Hostname?
« on: August 22, 2009, 03:40:22 PM »
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/asdf

I have setup a Controller Plugin:
Code: (php) [Select]
<?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:
Code: (php) [Select]
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.
whether you think you can, or can't, you're right -HF
Visit my website or github