In the following example the routes can determine if the URI is an alias, a file, a directory, or is the root path.

#!/usr/bin/ruby

# file: test.rb

require 'sinatra'


get '/' do
"home"
end

get '/:file*.*' do
"file"
end

get '/:alias' do
"alias"
end

get '/:directory/' do
"directory"
end



Tested (http://niko:4567) observed
----------------------- --------
/README alias
/README/ directory
/README/fun.txt file
/fun alias
/ home
/home.txt file
/home.txt/ file
/home/file.txt file
/home/f Sinatra doesn't know this ditty
/home/ directory
/home?edit=1 alias
/home/?edit=1 directory
/home.xml?edit=1 file


Note: Alias in this context means a URI which will be redirected to another URI

Resources:
- Sinatra: README [sinatrarb.com]

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/bI_RwZBxOqk/11051