简体   繁体   中英

Godaddy URL redirect from HTTP to HTTPS

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?

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 .

  • The CNAME record on Godaddy should be "www." instead of "www"
  • You should have only one redirect: example.com Redirect to https://www.example.com , and remove the other one.

Then you will probably have to allow quite a few hours for DNS changes to propagate, and it should work.

I have a similar configuation that works fine like this on a heroku Hobby plan (payed dyno) cf my recent post: SSL in Heroku with a custom domain

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.

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

I had the same task. GoDaddy supports Forwarding . Go to Domain DNS then at the bottom of the page, Forwarding 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM