Redirection
suggest changeYou can perform redirection in Rails routes as follows:
get "/stories", to: redirect("/posts")
match "/abc" => redirect("http://example.com/abc"), via: :all
match requires via:. Without it, Rails raises.
Put a catch-all last, or it swallows routes declared below it:
match "*path" => redirect("/"), via: :get
# or
get "*path" => redirect("/")
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents