Redirect to www for heroku with SSL

If you are using heroku and if you have enabled https then site must be redirected to use www . It means all Rails applications should ensure that “no-www” urls are redirected to “www”.

In Rails3 it is pretty easy to do. Here is how it can be done.

Bigbinary::Application.routes.draw do

  constraints(:host => /^ do
    root :to => redirect("")
    match '/*path', :to => redirect {|params| "{params[:path]}"}


No spam. Delivered around once a month.