# "fallback" routes

**URL:** <https://www.ruby-forum.com/t/fallback-routes/117650>\
**Category:** Rails\
**Created:** [October 18, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/fallback-routes/117650 "2007-10-18T23:09:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 18, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/fallback-routes/117650/1 "2007-10-18T23:09:13Z")

</div>

Hello list!

Is there a way to have a “fallback” route? Like if I have one  
:cat,:album,:item connected to AlbumsController.show, let’s say the  
:cat,  
:album or :item were invalid so other route would try to handle it.

The logic would be like this:

- Check if there’s an album/cat/item if not;
- Check if there’s an section/subsection/subsubsection
- and so on

Of course I could add a string prefix to the route to make it unique  
like  
this: /pages/:section/\* but it wouldn’t be as clean as :section/\*.

(Note: I’m not sure on how to handle unlimited arguments in the route  
in  
the case of the subsections example, I just put \* as an way to tell that  
there might be a unknown number of subsections, so if someone could also  
enlighten-me on this one, I would be grateful!)

Thanks,

Marcelo.

---

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [October 18, 2007, 11:53pm UTC](https://www.ruby-forum.com/t/fallback-routes/117650/2 "2007-10-18T23:53:40Z")

</div>

> Of course I could add a string prefix to the route to make it unique like  
> this: /pages/:section/\* but it wouldn’t be as clean as :section/\*.
> 
> (Note: I’m not sure on how to handle unlimited arguments in the route in  
> the case of the subsections example, I just put \* as an way to tell that  
> there might be a unknown number of subsections, so if someone could also  
> enlighten-me on this one, I would be grateful!)

# 

# Catchall to handle redirects for old site urls

# 

map.connect “\*args”, :controller =\> “url\_mapper”, :action =\> “index”

Then in your method look at: params[:args] to get an array of all the  
args (array is built by splitting on /)

-philip
