views:

99

answers:

1

I have a bunch of expired content at URLs all ending in .html from a legacy static HTML site:

example.com/a.html
example.com/b.html

Rather than display a Rails error page that says:

Routing Error
No route matches "/a.html" with {:method=>:get}

I want to reroute all content that ends in .html to the homepage (the root route):

map.root :controller => 'home', :action => 'index'

Is it possible to do this by only changing the route definition or is it necessary to define a catch-all route?

+2  A: 

You could do something like the following, in config/routes.rb:

map.connect ':pagename.html', :controller => 'home', :action => 'index'

See the Regular Routes section of the Rails Routing Guide for more information on this style of route.

Greg Campbell
Thanks !
apple