# Routes limitations : trailing / and more dynamic rules

**URL:** <https://www.ruby-forum.com/t/routes-limitations-trailing-and-more-dynamic-rules/49088>\
**Category:** Rails\
**Created:** [November 29, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/routes-limitations-trailing-and-more-dynamic-rules/49088 "2005-11-29T18:19:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/58f4c7/32.png) [@ericd](https://www.ruby-forum.com/u/ericd)\
**Post date:** [November 29, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/routes-limitations-trailing-and-more-dynamic-rules/49088/1 "2005-11-29T18:19:29Z")

</div>

Hello all,

I’ve two limitations in rails routes for which I don’t find a solution.

1. how to distinguish /hello/ from /hello ?  
Rails routes seem not use nor validate the trailing slash. routes  
‘hello’ and ‘hello/’ both validates urls ‘/hello’ and ‘/hello/’

2. how to have a dynamic ‘internal’ part in the url ?  
I would like to match everithing like %r{/.ht} so that the following  
routes are catch : /.htaccess /.htusers  
/hello/foo/barunlimited/number/of/path/.htaccess  
(I know that apache is already forbidding this ones, it is only an  
example)  
Rails routes let me write ‘:special\_with\_regexp/\*path\_info’ but not  
‘\*path\_info/:special\_with\_regexp’. Is there a way to do that ?  
It seems I can’t even do a regexp requirement on the \*path\_info to check  
all this by hand (at least I didn’t manage to do it).

From what I see rails routes as pretty limited. Is there a way to  
resolve my two needs ? If not, is there at least a (simple) way to take  
hand on routes to do ‘by hands regexp’ on the full url ?  
It seems that rails routes are more restricted and not very simpliers  
than plain regexp for my personnal needs.

And … maybe two ideas for feature request :

1. It would be cool if a could chain some routes. Say that “ok, url  
begin with /hello so put it in pipe A to finish dispatching”, “this one  
is not /hello but /foo, so finish dispatching with pipe B”. Something  
like sub-route.  
something like :  
map.connect\_with\_submap ‘hello/\*path\_info’ { |sub|  
sub.connect ‘foo/:controller/:action’, … # to check url  
/hello/foo/…  
sub.connect ‘bar/:controller/:action’, … # to check url  
/hello/bar/…  
}

2. I would be very convenient to be able to add a block to do  
additionnal checks by hands if the regexp is ok. Maybe something like :

# validates only if :id is a multiple of 2

map.connect ‘:controller/:action/:id’,  
:requirements =\> {:id =\> /\d+/}} ,  
{ |request, params| 0 == id % 2 }

Thanks in advance for any reply or idea.

–  
Eric D.
