2

This seems like it should be a trivial task but isn't proving to be one for me...

How should I go about pointing multiple domain names to the same GitHub Pages hosted site?

Example:

I have created an account named test on GitHub and created a repository test.github.io

I bought test.com

I configured test.com's DNS as below

I have told GitHub Pages to enforce https and look out for custom domain test.com

My site is now live on test.com and www.test.com, woohoo!

DNS Config for test.com:

A @ 185.199.108.153 (github's nameserver)

A @ 185.199.109.153 (github's nameserver)

A @ 185.199.110.153 (github's nameserver)

A @ 185.199.111.153 (github's nameserver)

CNAME @ www.test.github.io (for www redirect)

I would ALSO like example.com (and a few other domains, foo.com, bar.com and foobar.com) to redirect to test.com

How do I do this?
With an apache server, this would be easy, be GitHub Pages only supports static sites.

Any ideas?

As always, thanks for any suggestions!

Shep Sims
  • 698
  • 9
  • 27

2 Answers2

2

The ideal place to have this redirect is your DNS provider. You can redirect foo.com, bar.com, etc. or whatever you want to test.com. Alternatively, if you happen to use Cloud Flare, forwarding can easily be setup from there too.

But if you don't want to do that and insist on using Github only, refer to this answer. What you can do in this case is create another repository (other than test.github.io) with same contents and link it to another domain such as foo.com. You can use Github Actions or something to sync your changes from main repo to the others.

Of course, the only drawback of this method is that for every domain you want to link, you'll have to create an additional github repo.

Prahlad Yeri
  • 3,567
  • 4
  • 25
  • 55
  • How would you redirect with the DNS pointer? I know that if you have multiple sites with the same content then your SEO for both sites will be hit badly with duplicate content flags and cause all kinds of issues, so don't think last suggestion is an optimal solution. Thanks for linking that answer though, going to try out the HTML redirect solution and see how it performs. My initial thought is that it won't be great for page previews on search engines, but might make up for it with heightened SEO from the page links... will update after testing – Shep Sims Feb 02 '22 at 18:16
  • @ShepSims Your DNS Provider (GoDaddy, etc.) usually has a redirect feature through their online CMS/Panels. As for SEO impact, you can use the canonical tags to let Google know which one of the redirects is your original domain. – Prahlad Yeri Feb 03 '22 at 12:24
0

I've accepted @Prahlad Yeri's answer from above, and am just leaving this here so that other's who stumble onto this question can easily figure out how to do this... As mentioned "The ideal place to have this redirect is your DNS provider"

To do this with domains purchased from domain dot com it is VERY simple, and even INSTANTANEOUS! I can imagine with GoDaddy or other providers it will be similar.

On Domain dot com's control panel:

  1. Log into account for the domain you wish to redirect

  2. Go to "Pointers and Subdomains" on the left sidebar

  3. Choose either "URL Standard" or "URL Stealth" from the pointer options, then enter the desired redirect URL in the "Directory" field

  4. Press Save and you're good to go, immediately!

URL Stealth means that your URL will remain as what the user has typed in, and URL standard means it will display the URL of the site that you've directed to. More documentation on pointers and subdomains (for domain dot com) can be found at domain.com/help/article/domain-management-how-to-update-domain-pointers

Shep Sims
  • 698
  • 9
  • 27