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 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. smackaho.st and 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 lvho.st.

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.


§ 2 Responses to On Local Subdomains

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading On Local Subdomains at The On Blog.


%d bloggers like this: