Skip to content

Instantly share code, notes, and snippets.

@simonfranzen
Created December 2, 2018 18:56
Show Gist options
  • Save simonfranzen/f94b89d4bc7f1b4210c77670e57e4ab8 to your computer and use it in GitHub Desktop.
Save simonfranzen/f94b89d4bc7f1b4210c77670e57e4ab8 to your computer and use it in GitHub Desktop.
Redirect all routes in RubyOnRails
Rails.application.routes.draw do
constraints(:host => /^(?!old-domain\.com)/i) do
match "/(*path)" => redirect {
|params, req| "https://new-domain.com/#{params[:path]}"
}, via: [:get, :post]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment