Catching all non-matching URLs on Rails
One of the early things that I needed to for a web application, was to
try to map all unhandled or malformed URLs to be sent to Rails. It’s
important to do that especially when it’s too easy to make a mistake
typing on a URL, also because that instead of the typical
people normally see, Rails gives you an unsightly routing error, with a
“no route to match” message:
map.connect '*anything', :controller => 'controller', :action => 'action'
action with the desired controller and
action respectively. This will allow all unhandled URLs to be managed by
the controller of your choosing.