Rails - How to Redirect from http://example.com to https://www.example.com

前端 未结 6 691
感动是毒
感动是毒 2020-12-23 16:56

I\'m looking to learn how to cleanup my app\'s URLs. My app is powered by Rails 3 on Heroku.

The desired URL is https://www.example.comite.com

I

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 17:27

    As an extension to user2100689's answer, in Rails 3+ you can use config.force_ssl = true in config/environments/production.rb

    The line can just be uncommented as follows

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
    config.force_ssl = true
    

提交回复
热议问题