我使用本指南将静态网站部署到 Heroku:https ://devcenter.heroku.com/articles/static-sites-ruby
我创建了这个文件夹结构:
- site
|- config.ru
|- Gemfile
|- public
|- index.html
|- images
|- js
|- css
|- subfolder
|- images
|- js
|- css
并写信给config.ru
:
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public/subfolder"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
map '/subfolder' do
run Proc.new { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=6400'
},
File.open('public/subfolder/index.html', File::RDONLY)
]
}
end
现在我想要domain.com
指向public/index.html
和domain.com/subfolder
指向public/subfolder/index.html
。登陆页面似乎工作正常,我似乎无法将他们的请求提供给正确的目录(即正确images
的js
和css
文件夹)。
任何想法如何解决这个问题?谢谢!