Jump to content

Dynamic Subdomains & Zend_Controller_Router_Route_Hostname?


Recommended Posts

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:

<?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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.