Skip to content

Instantly share code, notes, and snippets.

@seratch
Created September 11, 2012 05:18
Show Gist options
  • Save seratch/3696130 to your computer and use it in GitHub Desktop.
Save seratch/3696130 to your computer and use it in GitHub Desktop.
Redirect Rack app
def redirect(arg)
new_host = 'new.example.com'
uri = arg["REQUEST_URI"]
[
302,
{'content-type' => 'text/plain', 'location' => "http://#{new_host}#{uri}"},
"http://#{new_host}#{uri}".chars
]
end
run method(:redirect)
# rackup -p 3000 -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment