Thursday, June 16, 2011

Subdomain module mapping with Zend Framework

Here is a very simple config to map a subdomain to a module with Zend Framework:
Samples:
Going abc.example.com/hello will route to
example.com/abc/hello/index

resources.router.routes.module.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.module.route = ":module.example.com"
resources.router.routes.module.defaults.module = "www"
resources.router.routes.module.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.module.chains.index.route = ":controller/:action/*"
resources.router.routes.module.chains.index.defaults.controller = "index"
resources.router.routes.module.chains.index.defaults.action = "index"

Just add this to your application.ini