Skip to content

Instantly share code, notes, and snippets.

@dented
Last active September 6, 2015 07:52
Show Gist options
  • Select an option

  • Save dented/10986237b9de315a5b86 to your computer and use it in GitHub Desktop.

Select an option

Save dented/10986237b9de315a5b86 to your computer and use it in GitHub Desktop.
Rails Redirect Old to New
class ApplicationController
before_filter :redirect_if_old
# before_action :redirect_if_old # if Rails 4+
protected
def redirect_if_old
if request.host == 'old.com'
redirect_to "#{request.protocol}new.io#{request.fullpath}", :status => :moved_permanently
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment