On Local Subdomains
January 17, 2012 § 2 Comments
I was working on a project a while ago that required the use of custom variable subdomains. If you have ever had to develop a site that used user specified subdomains, you quickly realize that editing your local
/etc/hosts file over and over again sucks. A lot. You end up setting up half a dozen subdomains on a dummy domain that points to
localhost. Not an ideal setup. Thanks to Railscast I tracked down a pretty cool solution to the problem.
The basic idea is to set up a live domain to point
127.0.0.1 and let DNS take care of everything for you. Tim Pope wrote about it nearly two years ago using
smackaho.st. In the Railscast Ryan Bates mentions another domain setup for this,
lvh.me, which was registred by Matthew Hutchinson.
lvh.me do the same thing, just on different domains. And because two isn’t enough, I went and registered
lvho.st and configured it to do the same thing as well. The
lvho.st domain comes from local virtual host, which I took from
lvh.me and the fact that I liked the thought of using a
.st domain like
smackaho.st so I could use
ho.st. Shove the two together and you get
Even though I don’t work with subdomains currently, I still use
lvho.st for local development. Anyways, feel free to use if you have the need.
Interesting side note, this same project is the one that inspired me to write my first ruby gem, tld-cookies. It’s a nice little gem that makes it easy to set a cookie that works across all subdomains instead of just the current one.
I recommend giving pow a try (http://pow.cx/).
Thanks .. it helped alot re: subdomain development