Rails: redirect all unknown routes to root_url

If your project is powered by rails 3, add simply this line to your routes.rb

match '*path' => redirect("https://stackoverflow.com/")

Edit: If you’re on Rails 4 or 5

match '*path' => redirect("https://stackoverflow.com/"), via: :get

or

get '*path' => redirect("https://stackoverflow.com/")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)