Serving up static sites on heroku - redux

First off, I should probably tell you that I totally ♥ Heroku . I run a bunch of little apps off it and at work believe it’s production ready for our main platform. A while back someone posted a nice little snippet of how to get a static site working on it in two lines of code on heroku, however, with some change in heroku, gem packaging or the like (or fact I added in multiple custom domains for the site), these static served pages suddenly stopped working. Counterintuitive when looked at, and even @radar and I together looking at it couldn’t figure it out. Anyhow, I puzzled the following out. Probably a few of the gems can be removed but this definitely worked for me.

# .gems*

rack-rewrite --version '>= 1.0.0'
# config.ru*

gem 'rack-rewrite', '~> 1.0.0'
require 'rubygems'
require 'rack'
require 'rack/rewrite'
require 'thin'

use Rack::Static, :urls => ["/css", "/images", "/index.html", "/contact.html", "/home.html", "/password.html"], :root => "public"

use Rack::Rewrite do
  rewrite '/', '/index.html'
end

run Rack::Directory.new('public')

This assumes you have a directory structure similar to the following :

.
|-- config.ru
`-- public
    |-- index.html
    |-- css
    `-- images