Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sethiele
Created March 4, 2014 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethiele/9343134 to your computer and use it in GitHub Desktop.
Save sethiele/9343134 to your computer and use it in GitHub Desktop.
Ruby Redirect Proxy
# encoding: utf-8
class LegacyUrlProxy
URL_MAPPING = {
'//surgeons-for-africa.com' => '//surgeons-for-africa.org',
}
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
dest_url = URL_MAPPING[request.path_info.gsub(/\/$/, '')]
if dest_url
[301, {'Location' => request.script_name + dest_url}, ['']]
else
@app.call(env)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment