I want to set up a permanent redirect of every path that begins with /articles
to the analogous path that begins with /blog
.
I know how to redirect paths individually in the routes, e.g.
match "/articles/" => redirect("/blog/")
However, if I also want to redirect paths such as /articles/:id
and /articles/category/:id
etc., I'll need to have explicit redirects for those as well.
I'm hoping that there's a way to redirect all such paths, present and future, with one fell swoop.
I realize that I could do this relatively easily in the controller with a before_filter
, but I believe this behavior belongs in the routes and I'm hoping to keep it there.
match '/articles(/*path)' => redirect { |params, req| "/blog/#{params[:path]}" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With