Routing An Old URL For A File To A Controller / Action


Currently users to my website download files from the following
structure of URL:

I would like to make it so that when the user navigates to the above URL
they are redirected to a controller / action. There are however about 50
files for download so I don't want a route for each one.

I have tried creating a controller called downloads but the file is
still accessed. I have also tried the following in routes.rb;

map.connect 'downloads/:folder/:filename', :controller =>
'controller_name', :action => 'index'

However this didn't work, the main reason for doing this is that I now
want to keep track of downloads from my website using google analytics
so I need a page to load in between, but, I don't want to break all the
other sites that link directly to my downloads.

I have also moved the downloads into another folder, so Rails must
evaluate the route but I just get no route matches errors from the

Thanks in advance,