1

is there a way i could route - http://localhost:3000/pages/1 to http://localhost:3000/home and all the other pages in my site i.e. - http://localhost:3000/pages/4 to http://localhost:3000/contact-us automatically?

I can do this the other way around using -

match "/home" => 'pages#show', :id => 1
match "/cars-for-sale" => 'pages#show', :id => 1
match "/contact-us" => 'pages#show', :id => 4

but need to do this in revers and automatically if possible.

oberfreak
  • 1,799
  • 13
  • 20
Robbie Done
  • 1,157
  • 9
  • 22

1 Answers1

0

Perhaps what you really need is a redirect:

match "/pages/1", :to => redirect("/home")
match "/pages/:id", :to => redirect("/contact-us")

Note, that the order is significant - "Rails routes are matched in the order they are specified" (see http://edgeguides.rubyonrails.org/routing.html)

Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53