Localhost subdomains with Mongrel on OSX

I’m writing a rails app that will use subdomains ala basecamp and tadalist, so that users will be organized into groupname.foo.com. I’m kind of new to unix so I’m trying to figure out how to handle subdomains locally with mongrel. Obvioiusly going to somesubdomain.localhost:3000 doesn’t work. I’ve hacked the /etc/hosts file to setup a local test url: www.localsite.com. I can use that to run locally and pick up subdomains but it feels like there has to be a better way. Any suggestions?

Also, in the etc/hosts file the * wildcard doesn’t seem to catch all subdomain s (ie. *.localsite.com)


I'm sure there must be a better way on OSX but I don't know what it is. When I need to dev local apps that use subdomains I just setup some etc/hosts aliases and use those: localhost.com engineyard.localhost.com ezmobius.localhost.com demo.localhost.com

-- Ezra Zygmuntowicz-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)

Agreed that I haven't found a way to do the * domains either -- what
is nice on OSX, however is editing the /etc/hosts file and then
running lookupd -flushcache to flush the dns cache so that it looks up
(and finds your /etc/hosts file) everytime.

We wrote an article on cleanair about subdomain auth and how to test:


let us know if you find anything.