Custom domains, www vs root, http vs https

Final Instructions So You Don’t Have To Wade Through Everything Above

If you have custom domain example.com that you want to point to example.glitch.me, here’s what to do:

  1. Add example.com and www.example.com as custom domains in Glitch. The order doesn’t matter.
Glitch config example screenshot

image

  1. Go to Domain Settings for example.com at your registrar. For Namecheap, choose “Namecheap BasicDNS”. Delete any existing domain redirects.

  2. Go to Advanced DNS settings (as it’s called in Namecheap) and delete any existing records.

  3. Add an A Record with host @ (meaning the root aka apex domain – example.com) and value 50.31.246.2 (the IP address for glitch.edgeapp.net – but check this with any dnslookup or ping service – it has changed before and everything breaks when it does, frustratingly). When testing and changing things, set the TTL to 1 minute. If you expect it to be stable, “Automatic” should be fine.

  4. Add a CNAME record with host www and value example.com. Same story with the TTL. (Note that Namecheap automatically turns example.com into example.com. with a trailing dot, which is expected.)

Registrar example config screenshot (note that the IP address shown is wrong though)

  1. It normally will work now, within like a minute. If it doesn’t, check https://dnspropagation.net/A/example.com to see if the DNS records are propagating. If it doesn’t start working in 3 days then you can definitively rule out “slow DNS propagation” as the culprit.

  2. For SEO reasons you want search engines to know which of the URL variants is the canonical one. This is called URL canonicalization aka “rel canonical”. Namely, pick a variant – let’s say https://www.example.com – as the canonical version of the URL and specify it in the header of the HTML like so:

<head>
...
<link rel="canonical" href="https://www.example.com"/>
...
</head>

That way search engines will not be confused and penalize you for having seemingly the same content duplicated across 4 (actually 6, counting http://example.glitch.me and https://example.glitch.me) different URLs.

  1. Redirect http to https. Doing this server-side is ideal, see full instructions, but for a static site, you can put the following in index.html:
<script>
if (window.location.protocol === 'http:')
  window.location.replace('https'+window.location.href.slice(4))
</script>
2 Likes