Rack::ForceDomain 04 February 2010

Usage:

use Rack::ForceDomain, ENV["DOMAIN"]
$ heroku config:add DOMAIN="foo.com"

Now when I go to www.foo.com/bannanas I will be 301d to foo.com/bannanas

Begin the ranting…

I couldn't find a simple gem to to just redirect stuff to a specific domain. They all (from my totally superficial search) seemed to either take too much configuration.

I just wanted to say “Make everyone go to spacelincoln.com”, but they wouldn't let me do that!

I had to tell them what domains to redirect from, and would explode when I didn't give them a domain. “Just make everyone go to spacelincoln.com!” I yelled in angry retribution.

This made me sad. So I did a gemmings.

Now www.spacelincoln.com, spacelincoln.co.uk and space-lincoln.heroku.com all go to spacelincoln.com (with a friendly 301 to the ass on the way out).