Saturday, July 29, 2006

Custom URLs with routes.rb

Using the routes.rb file, we can create custom URLs. It is important to note that the following is valid :

map.connect ':permalink', :action=>'list', :controller=>'categories'

whereas the following are not valid:

map.connect ':permalink-:id', :action=>'list', :controller=>'categories'
map.connect ':permalink_id.html', :action=>'list', :controller=>'categories'
map.connect ':permalink-:id.html', :action=>'list', :controller=>'categories'


At 6:46 AM, Blogger Luigi said...

Can you tell me how it's possible to generate an url with .html without using:

map.connect ':controller/:action/:id/:title.html'


Thank you

At 11:51 PM, Blogger Nilesh Patkar said...

This comment has been removed by the author.

At 11:53 PM, Blogger Nilesh Patkar said...

you can make it in http server level.
If you are using apache then use mod_rewrite and rewrite rules. If you are using webrick then you can check this article

You can also check this project RDR :: Rails Dynamic Routes on rubyforge, which is a little step towards having dynamic routes in rails.

At 4:11 PM, Blogger Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.
Oes Tsetnoc | Semangat Mengembalikan Jati Diri Bangsa


Post a Comment

<< Home

eXTReMe Tracker