For some reason this took me a long time to figure out, so I thought I’d post it in case other people are having similar problems. I wanted www.mysite.com to route to the www module and app.mysite.com to route to the app module. In the end it was quite simple—I was trying to make it much more complicated than it needed to.
I’m using Zend Framework 1.8.4 with Zend_Application
Here’s my router configuration:
resources.router.routes.www.type = "Zend_Controller_Router_Route_Hostname" resources.router.routes.www.route = ":module.mysite.com" resources.router.routes.www.defaults.module = "www" resources.router.routes.www.chains.index.type = "Zend_Controller_Router_Route" resources.router.routes.www.chains.index.route = ":controller/:action/*" resources.router.routes.www.chains.index.defaults.controller = "index" resources.router.routes.www.chains.index.defaults.action = "index"
And here’s my .htaccess rule that redirect to www if another subdomain is used (or no subdomain is given):
RewriteCond %{HTTP_HOST} !^(www|app)\.mysite\.(com|local)
RewriteRule ^(.*)$ http://www.mysite.%2/$1 [R=302,QSA,L]Otherwise it’s just your standard modular structure generated with the zf tool.
Additional comments powered by BackType
You can leave a response, or trackback from your own site. Follow any responses to this entry through the RSS 2.0 feed.
Thank you! your a legend. Though I haven’t tried it yet, it shall be a help!