Ruby on Rails: Route a deprecated URL to application's root -
how write rails route in config/routes.rb when need point deprecated url still exists on else's website can't control ('/something/article.jsp?id=1787'
) root of application?
how below (wrong) attempt need corrected?
get '/something/article.jsp?id=1787' => 'root#index'
you can specify constraint
:
get '/something/article', to: redirect('/'), :constraints => lambda { |request| request.params[:id] == '1787' }
this creates 301 "moved permanently" redirect.
if don't want redirect, instead want url trigger root#index
action, can substitute to: redirect('/')
line to: 'root#index'
. however, approach keep old url in address bar.
hope helps!
Comments
Post a Comment