Search code examples
ruby-on-railsnginxruby-on-rails-2

Have subfolder show index.html - Rails / nginx


I have a subdirectory on my rails app that I want entirely static. My problem is that I am unable to visit /subdirectory/ and have it show index.html, I have to go to /subdirectory/index.html.

How can show the index files for subdirectories? I'm using nginx and rails 2.3.11


Solution

  • you set up what the indexfile is with the index directive described at http://nginx.org/en/docs/http/ngx_http_index_module.html#index

    alternatively you could add trying the index.html explicitly to your try_files directive for your subdir location:

    location /static-subdir/ {
      try_files $uri $uri/index.html;
    }