I have two routes in routes.rb
get 'schools/*criteria', to: 'schools#show'
// need this route to redirect to above route
get 'schools/*criteria/school-[a-zA-z]' ,to: redirect('schools/*criteria', status: 301)
Ex: when I try this url /schools/elementary/school-c it has to redirect to /schools/elementary. but it is not happening.
Any help will be appreciated.
答案 0 :(得分:2)
您可以尝试使用constraint
并将title
传递给参数
get 'schools/*criteria/:title', constraint: { title: /school-[a-zA-z]/ } ,to: redirect('schools/*criteria/%{title}', status: 301)