How can I use rails routes for dynamic 301 redirects?
I need to setup 301 redirects for my old URL's which have quiet high PR's.
Indexed URL's are in this format:
www.mysite.com/search/find?category[id]=7-Farming
and want to redirect them, using 301,开发者_StackOverflow中文版 to:
www.mysite.com/categories/find/farming
In the 1st URL 7 is the id of the farming category, in the 2nd URL "farming" is a permalink.
I think I need to parse the id from the first URL, lookup using AR the farming category to get its permalink then redirect somehow.....just not really sure what the best / cleanest way to do this is.
Any advice would be very much appreciated!
When you make a redirect_to in a controller it sends a 301 to the user browsers.
Just do as you said, grab the category and use a redirect_to.
精彩评论