0

I'm trying to redirect my root domain: http://[sitename].com to https://www.[sitename].com

  • Backend is rails on heroku with a Hostname Base SSL.

  • My domain is registered on GoDaddy.

And, here is what I've tried:

  • In my ApplicationController, I have a before_filter called redirect_to_https. And the contents of that are:

    def redirect_to_https
        puts "In Redirect"
        redirect_to "https://www.[sitename].com#{request.fullpath}" unless request.ssl? || !Rails.env.production?
    end
    

When I browse to the root domain of the website, I do not see the "In redirect" in the logs. So, clearly that redirect is not actually working.

Any ideas?

amehta
  • 439
  • 6
  • 14

1 Answers1

0

I would look at Rack-rewrite, it's a much more efficient lower level library that does all this sort of thing really well. Alternatively, roll your own:

http://www.simonecarletti.com/blog/2011/05/configuring-rails-3-https-ssl/

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134