I have a domain running on example.com and https://example.com
on Heroku. I have a URL redirect on my name server from www to https://example.com
. I have config.force_ssl = true
set in config/environment/production.rb
. The domain URL redirect works only on http, not https. It works in Chrome the first time I type www.example.com. However it fails the 2nd time I use www.example.com. It gives a 'ERR_CONNECTION_REFUSED' with a 307 Internal Redirect.
Status Code: 307 Internal Redirect
Location: https://www.example.com/
Non-Authoritative-Reason: HSTS
This is despite the domain service always giving Location: https://example.com
via curl
. Where is Chrome getting https://www*
from? I saw https://superuser.com/a/881431/130929 about deleting the HSTS entries from Chrome at chrome://net-internals/#hsts
. If I do that for both example.com and www.example.com, then it works only the first time for www.example.com again. example.com and https://example.com
always works. What's worse is that in Firefox, after loading the page, simply using example.com fails because Firefox automatically adds a https://www
. How can I use HTTPS on the root domain and redirect www to the root domain? I don't care about handling https://www.example.com
as no one would type that. They would only mistakenly type www.example.com.