Skip to content

Instantly share code, notes, and snippets.

@dpickett
Created March 30, 2012 23:21
Show Gist options
  • Save dpickett/2257788 to your computer and use it in GitHub Desktop.
Save dpickett/2257788 to your computer and use it in GitHub Desktop.
rewrite
run lambda do |env|
req = Rack::Request.new(env)
Rewrite.find_each do |rewrite|
if request.path =~ Regexp.new(rewrite.source)
return [301, {'Content-Type'=>'text/html', 'Location'=>"#{rewrite.destination}"}, ['Redirecting...']]
end
end
super
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment