最近、Herokuの新しい杉スタックへのアップグレードで問題が発生しました。そこで、古いWebサイトを、以下のsinatraコードを使用する静的なパブリックフォルダーにダンプすることで、この問題を回避しました。
ただし、古いURLへのリンクは、URLの末尾に.htmlを追加できないため、静的ページをロードしません。
require 'rubygems'
require 'sinatra'
set :public, Proc.new { File.join(root, "public") }
before do
response.headers['Cache-Control'] = 'public, max-age=100' # 5 mins
end
get '/' do
File.read('public/index.html')
end
すべてのURLの末尾に.htmlを追加するにはどうすればよいですか?これは次のようになりますか?
get '/*' do
redirect ('/*' + '.html')
end