Routing to static html page in /public

Aen Tan picture Aen Tan · Apr 12, 2011 · Viewed 55.8k times · Source

How can I route /foo to display /public/foo.html in Rails?

Answer

Arkan picture Arkan · Apr 12, 2011

You can do this:

Add this, into your routes.rb file.

match '/foo', :to => redirect('/foo.html')

Update

In Rails 4, it should use "get", not "match":

get '/foo', :to => redirect('/foo.html')

thanks Grant Birchmeier