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

**URL:** <https://www.ruby-forum.com/t/routing-an-old-url-for-a-file-to-a-controller-action/129990>\
**Category:** Rails\
**Created:** [February 23, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/routing-an-old-url-for-a-file-to-a-controller-action/129990 "2008-02-23T21:07:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![digitalpardoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cc9497/32.png) [@digitalpardoe](https://www.ruby-forum.com/u/digitalpardoe)\
**Post date:** [February 23, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/routing-an-old-url-for-a-file-to-a-controller-action/129990/1 "2008-02-23T21:07:36Z")

</div>

Hi,

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

[http://thewebsitefortest.com/downloads/folder/filename.dmg](http://thewebsitefortest.com/downloads/folder/filename.dmg)

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  
above.

Thanks in advance,  
Alex
