Reassign https://example.com to https://www.example.com: Namecheap and Heroku

I am trying to redirect all requests to:

https://example.com http://www.example.com http://example.com 

to https://www.example.com . I use Heroku and Namecheap.

Here are my steps:

  • At Heroku, I added www.example.com to my domains and enabled SSL.
  • In Namecheap, I created a CNAME record with the host www to www.example.com.herokudns.com.
  • In Namecheap, I created a URL Redirect entry with host @ up to https://www.example.com/ .

Everything works fine with these steps, as long as I redirect http requests to https requests on the server side (for example, redirect http://www.example.com/ to https://www.example.com/ ).

The only thing I cannot understand is to redirect https://example.com to https://www.example.com . From what I read, it looks like it could record ALIAS . Unfortunately, Namecheap does not have this type of record.

Is it possible to get this behavior using Namecheap, or do I need to use another DNS provider?

+8
source share
2 answers

AS for the hero

DNS A records can be used to configure the zones of the upper domains (also called open, open, or root domains). These records have serious implications for availability when used in environments such as on-premises data centers, cloud infrastructure services, and platforms such as Heroku.

Restrictions on DNS records require the IP address to be hard-coded in the configuration of your DNS application. This does not allow your infrastructure provider to assign your application a new IP address on your behalf in the event of adverse conditions and can seriously affect the operating time of your applications.

The CNAME record does not require hardcoded IP addresses and allows Heroku to manage the set of IP addresses associated with your domain. However, CNAME records are not available at the top of the zone and cannot be used to configure root domains.

Since a service such as namecheap does not allow you to specify bare somain via CNAME, you need to add pointDNS or use the cloudflare pointing service to achieve the same result, otherwise all websites will work except ssl with an open domain.

0
source

For those who still have this problem, I found a solution with Namecheap to redirect the root domain to a subdomain.

  1. I pointed my subdomain to the location of my site (in this case, on Github)
  2. I created a CNAME record for @host and made it my subdomain value

This redirects my root domain to my subdomain.

0
source

Source: https://habr.com/ru/post/1266443/


All Articles