How to redirect a url like https://mydomain.com to https://www.mydomain.com from Rails

I am using an SSL certificate for www.mydomain.com from GoDaddy on Heroku. How can I redirect from the root https://mydomain.com URL to https://www.mydomain.com from rails so that my certificate works? I was able to redirect all other combinations using special middleware, so SSL is always server-side, but cannot figure out how to do this if the browser does not detect a lack of certificate for https://mydomain.com/ . Is there something like an env [HOST] rack that I can rewrite? Thanks in advance.

+4
source share
1 answer

The browser compares the certificate with the domain name before Rails even gets the opportunity to touch it - this is actually the very first part of the negotiations with the server, so you can not even use Apache Rewrite to change it.

What you need to do is add mydomain.com to your certificate. They are called the Unified Communications Certificate, although GoDaddy simply calls them the certificate of several domains. http://help.godaddy.com/article/3908

+4
source

All Articles