Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I implement a redirects-only rack-based heroku application?

I would like to create an rack application for deployment of heroku to create some 301 redirects to other subdomains.

If the path would be carried over, it would be nice.

I started with the following code, but it isn't working:

require 'rack-force_domain'

use Rack::ForceDomain, ENV["DOMAIN"]

run lambda { |env| [200, {'Content-Type'=>'text/plain'}, StringIO.new("Hello World!\n")] }
like image 812
rriemann Avatar asked May 10 '26 02:05

rriemann


1 Answers

I solved this problem by using sinatra finally. That's my config.ru:

require 'sinatra'

get %r{(.*)} do
  redirect to("http://custom.domain#{params[:captures].first}"), 301
end

run Sinatra::Application
like image 186
rriemann Avatar answered May 12 '26 23:05

rriemann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!