Ruby on Rails Redirection


Example

You can perform redirection in Rails routes as follows:

4.0
get '/stories', to: redirect('/posts')
4.0
match "/abc" => redirect("http://example.com/abc")

You can also redirect all unknown routes to a given path:

4.0
match '*path' => redirect('/'), via: :get
# or
get '*path' => redirect('/')
4.0
match '*path' => redirect('/')