Reputation: 1832
I want to redirect http://mysite.com/docs/some-old-link to http://mysite.com/docs/some-new-link (some-old-link is gone). Here's what I'm trying:
resources :docs, :only => [:index, :show] do
member do
match "some-old-link" => redirect("some-new-link")
end
end
But the redirect isn't happening and I just get 404 on some-old-link. Tried various tweaks on this but can't get it. How do I do this?
Upvotes: 1
Views: 1266
Reputation: 8928
First, try to add "to" to your code:
match "some-old-link", to: redirect("some-new-link")
The problem also could be:
member do
match "some-old-link" => redirect("some-new-link")
end
Is expected to redirect sth like this:
/docs/id/some-old-link to /docs/id/some-new-link
try using collection instead of member
Upvotes: 4