redirect blog path to subdomain

This commit is contained in:
Kyle Drake 2015-07-23 17:27:37 -07:00
parent 07a1d569b7
commit 766ca009ca

View file

@ -1,22 +1,7 @@
require 'net/http'
require 'uri'
get '/blog/?' do get '/blog/?' do
expires 60, :public, :must_revalidate redirect 'https://blog.neocities.org', 301
return Net::HTTP.get_response(URI('http://blog.neocities.org')).body
end end
get '/blog/:article' do |article| get '/blog/:article' do |article|
expires 60, :public, :must_revalidate redirect "https://blog.neocities.org/#{article}.html", 301
attempted = false
begin
return Net::HTTP.get_response(URI("http://blog.neocities.org/#{article}.html")).body
rescue => e
raise e if attempted
attempted = true
article = article.match(/^[a-zA-Z0-9-]+/).to_s
retry
end
end end