0
votes

I am converting my old ASP.NET sites to Ruby on Rails sites and I wanted to know the best way to redirect the old .aspx pages to Ruby on Rails routes using the same domain. The new Ruby on Rails version of the site is on a different server but I obviously want the domain to be the same. For example, how do I redirect www.mydomain.com/product.aspx?productid=1 to www.mydomain.com/product/1 while the domain/DNS is transferred to the new server where the Ruby on Rails app is hosted? I can easily just switch the DNS to the new server and everything would work fine but I don't get the SEO and legacy url benefit of having those old .aspx pages redirect to the new Ruby on Rails routes. The search engines would never know so I would lose all page ranking and would have to start all over again.

Any advice on the best way to approach this?

1

1 Answers

2
votes

Ideally you want to handle this sort of thing before it hits Rails, say with Apache mod_rewrite rules if you're using Phusion Passenger and so on.

That said, you can still set up permanent redirects in your routes.rb if you want it to be within your app:

get 'product.aspx?productid=:id', to: redirect('/product/%{id}')