views:

178

answers:

1

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, 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!

A: 

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.

robertokl
Thanks, I am wondering though if I can do all this just from the routes file rather than using a controller
Jason
I don't think so because you have to find the permalink given an id, right?Routes file is not the right way to do so..You could create a controller just to do that and you send all yours "old path" to the same controller.Is it so bad?
robertokl