Routing based on host domain

I’m having some problems getting routes to work based on the incoming
host domain.

Imagine the top level domain for my app is foo.com. If the user comes
in with a request of:

I would like to route them to the public home page

If they come in with anything else I want to route them to their account
home page, i.e.:

I’ve been using the account_location plugin to help with the parsing and
redirecting of the account subdomains which works great. What I can’t
figure out is the routing. I would like to write something like this:

map.public_home ‘’, :controller => ‘page’, :action => ‘home’,
:requirements => { :host => /^(www.)?foo.com$/i }

map.account_home ‘’, :controller => ‘account’, :action => ‘view’

So when the request goes through the table it would call the correct
controller/action based on the host requirement. If the host is
www.foo.com or foo.com (no subdomain) it goes to the home page,
otherwise go to the account hoem.

What actually happens is the :requirements are ignored and the first
route always handles. I have some hackery in there to redirect to the
correct location but I’d rather handle this the “correct way”.

Any suggetions?