Rails: redirect all unknown routes to root_url

后端 未结 5 1619
粉色の甜心
粉色の甜心 2020-11-30 23:02

Whenever a user hits the wrong page, rails shows 404.html from the public folder. However, I\'d like just to redirect the browser to the root page, without showing anything.

5条回答
  •  天涯浪人
    2020-11-30 23:28

    Like the answer by Arkan. One point, if do not want this behaviour in development environment, then could do -

    match '*path' => redirect('/')   unless Rails.env.development?
    

提交回复
热议问题