Created
September 19, 2011 18:20
-
-
Save mitio/1227170 to your computer and use it in GitHub Desktop.
Permanent redirects in routes.rb, while preserving query-string args
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
# take care of old, legacy routes | |
redirect_with_query_string = lambda do |path| | |
redirect do |params, req| | |
path << "?#{req.query_string}" unless req.query_string.blank? | |
path | |
end | |
end | |
# example usage | |
match 'legacy_root_path' => redirect_with_query_string.call('/') | |
match 'studios/props' => redirect_with_query_string.call('/studios/gear') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment