About Chris Morrell

I am a Philadelphia web designer and developer who focuses on PHP development and usable design. I am also the Director of IT for the International Association of Certified Home Inspectors.

Please Note: My site fell victim to a Wordpress security flaw a few weeks ago, and I'm just getting everything back to normal. Please bear with me.

I am currently not accepting any new clients.

Other Sites/Clients

Contact Me

If you need to get in touch with me, my name is Chris and my domain name is cmorrell.com. Think about it.

Mapping subdomains to modules in Zend Framework

Posted by Chris Morrell on July 7th, 2009 in Web Development (tagged )

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.

1 Comment »

One Response to “Mapping subdomains to modules in Zend Framework”

  1. Ashley Simons

    Thank you! your a legend. Though I haven’t tried it yet, it shall be a help!

Leave a Reply

Additional comments powered by BackType

Comments & Trackbacks

You can leave a response, or trackback from your own site. Follow any responses to this entry through the RSS 2.0 feed.

More...

@inxilpro

  • Nice! Google Maps now does biking directions! 1 day ago
  • Updated my Flickr/Tweetie bridge w/ a few more options. Lets you use flic.kr URLs in Tweetie 2. http://bit.ly/c0PEIm 3 days ago
  • I'm so goddamn sick of web site password restrictions. You're Bank of America, but you can't handle special characters in my password? 3 days ago
  • More updates...
Copyright © Chris Morrell, Powered by WordPress, Entry RSS Feed / Comment RSS Feed