Reputation: 2067
We've built up thousands of product urls while using Magento as our cart application and these URLs are not at all intuitive or that SEO friendly, despite having built up our search rankings on them.
We are transitioning to Rails 3 (with Spree as our cart) and would like to clean up our URLs. I'm wondering what's the cleanest way to handle potentially thousands of 301 redirects in Rails? Hard coding that many in routes.rb does not seem sane.
Possibly pertinent info:
We're tied to using Heroku for at least the next few months.
Upvotes: 1
Views: 374
Reputation: 16064
The best way to do this would be with a route glob. In routes.rb:
match 'products/*product_url' => 'products#redirect_to_real_product'
As long as this match is underneath all your other product matching, it'll connect to ProductsController#redirect_to_real_product with a helpful param[:product_url] that you can perform scanning and lookup on to redirect the user to the correct product.
Upvotes: 3