Can github pages CNAME file contain more than one domain?

Can github pages CNAME file contain more than one domain?

Example file:

reggi.com
www.reggi.com
blog.reggi.com

Solution 1:

No, this is not possible. See the GitHub Help docs that explain this:

Ensure you only have one domain listed in your CNAME file. If you wish to have multiple domains pointing to the same Pages, you will need to set up redirects for the other domains. Most domain registrars and DNS hosts offer this service to their customers.

Solution 2:

Here is one approach that is a Github-only solution using an HTML redirect.

  1. Create an extra repository
  2. Configure it to use Github Pages with the additional domain
  3. Add an an index.html file with the following contents
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Redirecting to https://example.com</title>
    <meta http-equiv="refresh" content="0; URL=https://example.com">
  </head>

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

Solution 3:

You can have only one domain name in the CNAME file. Additionally you can setup forwarding (optionally with masking) on your other domains.

Without masking, it is like a redirect to your original website where the url in the browser will show your original website.

With masking, it will serve contents from your original website and the url in the browser will show the new one.

I have setup forwarding with masking for my blog. You can check out the following links to see how that works.

Original blog: http://hemanshubhojak.com

Forwarded blog: http://batcode.net