6

I host my website on heroku and bought the domain from godaddy, here's how I set my DNS records

Records

A - @ - Forwaded - 600 secs

CNAME - www - example.com.herokudns.com - 1 Hour

Forwarding

-- Domain --

Redirect to https://www.example.com

-- Subdomain --

example.com Redirect to https://www.example.com

www.example.com Redirect to https://www.example.com

Expected Behaviour

When I enter example.com or www.example.com, it should redirect to https://www.example.com

Result

Only example.com got redirected to https://www.example.com, www.example.com does not

What went wrong with my configuration ?

Matt Downey
  • 363
  • 6
  • 18
  • You may need to check your code again. If you use https, please make sure the SSL has been installed properly. If you want to redirect http to https, then please make sure you use URL redirection on your code. – Mark Spencer Nov 07 '17 at 04:20
  • Did you ever solve this? got the same problem... – DeeFisher Jan 25 '22 at 22:59

3 Answers3

1

You can't have www as a CNAME and also www as a redirect. If you have the www CNAME aliased to example.com.herokudns.com it's going to go directly to your app on Heroku and make a connection. Your app must be the one to force the redirect to https at that point. I don't know what language you are using, but if it's Rails then set config.force_ssl = true in production.rb.

Chloe
  • 25,162
  • 40
  • 190
  • 357
0

If your domain is pointing at Heroku with an A and a CNAME record, then the "forwarding" settings on GoDaddy will have no effect. To implement forwarding, GoDaddy points the domain to their own servers.

Once you point the domain at Heroku, all HTTP to HTTPS redirects have to be implemented at Heroku. You can no longer use Godaddy's forwarding. In any case, GoDaddy's URL forwarding is badly implemented and unreliable. You should never use it. See GoDaddy's 301 redirect/forwarding has some weird random middleman URL, kills link juice?

How to redirect HTTP to HTTPS at Herouku depends on what programming language you use. Basically, the redirect rule has to be programmed into your application. See their documentation for specific instructions for a variety of cases: Can Heroku force an application to use SSL/TLS? - Heroku Help

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
-1

To actually use the Domain as the Web Address: The A Record should be the IP Address The CNAME only needs to be name: www value: @

Also I like to keep the TTL the same for the A and CNAME records. Wait about an hour before testing to ensure the servers have propagated.

For Domain forwarding you only need to scroll down to Forwarding and select https or http (make sure that is correct). Then the web address/url to the home page.

Use a permanent redirect for SEO.

  • A `CNAME` can point to `www` or it can point to a value given to you by your hosting company. It is not wrong to to the latter as this answer suggests. – Stephen Ostermiller Aug 19 '22 at 10:20