Search code examples
http-redirectdnsgithub-pagescnamenamecheap

Github pages <> Namecheap, Apex domain to redirect to subdomain


I'm using Github pages for hosting. Namecheap for DNS.

I want if going to "example.com" to send web browser requests to -> "blog.example.com."

I'm able to create and verify a custom domain on github pages for blog.example.com and it works, but not understanding how to redirect the apex root domain to blog.example.com.

Recap: Custom github pages domain: blog.example.com && Namecheap: CNAME blog => example.github.io.

I tried removing all the suggested github A, AAAA records and trying the use of a URL redirect/301 and also tried an alias record of

"@" -> blog.example.com

URL redirect seems to result in a timeout, and the Alias record seems to result in going to github with a 404.

Seems these are the relevant github pages docs: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#configuring-a-subdomain

I've looked through this to no avail.

Am I doing something wrong?

Side Question: I'm unsure if the CNAME file is required in github directory as I feel it's more or less for documentation? (changing this file doesn't seem to have any effect.)


Solution

  • I suppose I was just not being patient, unmasked redirect started working no problem after a while.