Ruby Rack Heroku: Serving Static Files

I have followed the Heroku guide on deploying static files using Ruby Rack (, but I was unable to access any HTML file in \public apart from index.html. Namely, localhost:9292/test.html still maps to index.html. (All my style and js files serve correctly).

Below is my file. I know what's wrong, but not sure about a valid solution?

use Rack::Static,    :urls => ["/images", "/js", "/css"],   :root => "public"

run lambda { |env|   [
      'Content-Type'  => 'text/html', 
      'Cache-Control' => 'public, max-age=86400' 
    },'public/index.html', File::RDONLY)   ] }


For your file, try:

use Rack::Static,
    :urls => ["/images", "/js", "/css"],
    :root => "public"


You could also replace the last line with run"public") which would serve up all your files, but would give a file browser like interface if someone went to the url of a directory (like the root directory)

I have no Ruby experience and I found this boilerplate project helpful when trying to deploy a static website to Heroku:


Particularly, make sure you also have Gemfile and Gemfile.lock files besides the

Author's project structure hosts everything in the root directory but you can easily move everything to public/ and correct the as @looby suggested.

Need Your Help

$.when.apply on Array of Promises

javascript jquery ajax promise deferred

I have searched many very similar questions. I found one that had almost exactly what I was looking for except it did not have any error handling, and upon trying to implement error handling I am r...