---
title: "Redirect to www for heroku with SSL"
description: "How to redirect to https version of the url."
canonical_url: "https://www.bigbinary.com/blog/redirect-to-www-heroku-ssl"
markdown_url: "https://www.bigbinary.com/blog/redirect-to-www-heroku-ssl.md"
---

# Redirect to www for heroku with SSL

How to redirect to https version of the url.

- Author: Neeraj Singh
- Published: October 12, 2012
- Categories: Rails

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.

```ruby
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
```

## Links

- [Human page](https://www.bigbinary.com/blog/redirect-to-www-heroku-ssl)
