# Nice urls?

**URL:** <https://www.ruby-forum.com/t/nice-urls/139655>\
**Category:** Rails\
**Created:** [June 5, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/nice-urls/139655 "2008-06-05T20:42:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/1 "2008-06-05T20:42:57Z")

</div>

Can anyone please explain to me how to get ugly urls like :

[hostname.com/browse/day?cal\_name=name&day=9&month=6&year=2008](http://hostname.com/browse/day?cal_name=name&day=9&month=6&year=2008)

to be something nice like:

[hostname.com/browse/name/day/month/year](http://hostname.com/browse/name/day/month/year)

or something like that?

I’ve read a bit about routes but I don’t see any examples anywhere  
really of how to do this.

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 8:57pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/2 "2008-06-05T20:57:54Z")

</div>

On Jun 5, 2008, at 2:42 PM, Amanda … wrote:

> I’ve read a bit about routes but I don’t see any examples anywhere  
> really of how to do this.

map.connect ‘browse/:cal\_name/:day/:month/:year’, :controller =\>  
‘browse’, :action =\> ‘day’

Assuming that the default route was picking up your example URL.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 9:00pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/3 "2008-06-05T21:00:03Z")

</div>

> map.connect ‘browse/:cal\_name/:day/:month/:year’, :controller =\>  
> ‘browse’, :action =\> ‘day’
> 
> Assuming that the default route was picking up your example URL.
> 
> -Rob
> 
> Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
> removed\_email\_address@domain.invalid

where do I do that?

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 9:03pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/4 "2008-06-05T21:03:29Z")

</div>

and also, since the :day, :cal\_name etc are parameters would I have to  
do ‘browse/params[:cal\_name]/params[:day]/…’?

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 9:34pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/5 "2008-06-05T21:34:06Z")

</div>

On Jun 5, 2008, at 3:00 PM, Amanda … wrote:

> where do I do that?

In your project’s config/routes.rb file, of course.

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 9:38pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/6 "2008-06-05T21:38:14Z")

</div>

oh lol thanks so much!

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 5, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/7 "2008-06-05T21:42:58Z")

</div>

Amanda,

You may want to read into how you can setup customer routes using the  
routes.rb files in rails… Furthermore you may want to read into  
RESTful development, and how rails deals with Resources etc… might  
help with your issue here.

There’s a TON of information on this on the net, and there’s just too  
much to go through here…

---

<div class="post-metadata">

**Author:** ![amanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/67e7ee/32.png) [@amanda](https://www.ruby-forum.com/u/amanda)\
**Post date:** [June 6, 2008, 1:09pm UTC](https://www.ruby-forum.com/t/nice-urls/139655/8 "2008-06-06T13:09:04Z")

</div>

Or, I find The Rails Way by Obie F. exceptionally clear on this  
topic. Excellent book in many ways, but it seems to really shine on  
routings.

Ron
