# Migrating to rails... best way to redirect old urls?

**URL:** <https://www.ruby-forum.com/t/migrating-to-rails-best-way-to-redirect-old-urls/62981>\
**Category:** Rails\
**Created:** [June 10, 2006, 2:05am UTC](https://www.ruby-forum.com/t/migrating-to-rails-best-way-to-redirect-old-urls/62981 "2006-06-10T02:05:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phallstrom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@phallstrom](https://www.ruby-forum.com/u/phallstrom)\
**Post date:** [June 10, 2006, 2:05am UTC](https://www.ruby-forum.com/t/migrating-to-rails-best-way-to-redirect-old-urls/62981/1 "2006-06-10T02:05:28Z")

</div>

Hey all -

I’m migrating an app from PHP to Rails and was wondering what the best  
way  
to redirect the old urls are. I would like to do a 301 as I’m told that  
makes Google the happiest.

We’re using lighty as the server and I believe it has rewrite  
capabilities, but I can’t get to their site right now.

Anyway, I’m wondering if it’s best handled in lighty? Or by adding a  
bunch of routes, or by having a handler catch what would be 404’s then  
run  
some custom code and if I can find a match, redirect them, otherwise,  
return 404.

We have quite a few urls and I’d like to automatically map as many as  
possible.

Seems like the last option would be best since it would only happen if  
rails didn’t catch it already…

Pointers? Suggestions?

Thanks!

-philip

---

<div class="post-metadata">

**Author:** ![phallstrom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@phallstrom](https://www.ruby-forum.com/u/phallstrom)\
**Post date:** [June 10, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/migrating-to-rails-best-way-to-redirect-old-urls/62981/2 "2006-06-10T18:54:22Z")

</div>

> a handler catch what would be 404’s then run  
> some custom code and if I can find a match, redirect them, otherwise,  
> return 404.

id stick with routes.rb rather than inventing your own, since it works  
quite well and you can constrain by regex if needed…

> We have quite a few urls and I’d like to automatically map as many as  
> possible.

routes.rb for the ones youd like to keep, and send the rest to the  
301/404 bin. redoing a drupal site in rails my threshold was do the  
names even make sense. eg /article/tagname was ditched, since id expect  
an articleid or shorturl to follow, not a tag… use your judgement, i’m  
sure its good…

---

<div class="post-metadata">

**Author:** ![phallstrom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@phallstrom](https://www.ruby-forum.com/u/phallstrom)\
**Post date:** [June 10, 2006, 9:25pm UTC](https://www.ruby-forum.com/t/migrating-to-rails-best-way-to-redirect-old-urls/62981/3 "2006-06-10T21:25:06Z")

</div>

On Jun 9, 2006, at 5:04 PM, Philip H. wrote:

> a bunch of routes, or by having a handler catch what would be 404’s
> 
> Thanks!
> 
> -philip
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Philip-

```
There is a funny plugin out there called Legacy Interop. Which

```

allows your to emulate your old urls. Check it out , it might help  
you transition your app over to rails.

[http://wiki.rubyonrails.com/rails/pages/Legacy+Interop](http://wiki.rubyonrails.com/rails/pages/Legacy+Interop)

-Ezra
