Last active
September 6, 2015 07:52
-
-
Save dented/10986237b9de315a5b86 to your computer and use it in GitHub Desktop.
Rails Redirect Old to New
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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