BigBinary Blog

We write about Ruby on Rails, React.js, React Native, remote work, open source, engineering and design.

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 => /^bigbinary.com/) do
    root :to => redirect("http://www.bigbinary.com")
    match '/*path', :to => redirect {|params| "http://www.bigbinary.com/#{params[:path]}"}
  end

end
Neeraj Singh in Rails
12, 2012
Share

You might also like

Rails 6.1 adds support for PostgreSQL interval data type

Rails 6.1 allows per environment configuration support for Active Storage

Rails 6.1 adds support for belongs_to to has_many inversing

Rails 6.1 adds strict_loading to warn lazy loading associations

Rails 6.1 adds where.associated to check association presence

Subscribe to our newsletter