Multiple GitHub Pages and custom domains via DNS

匆匆过客 提交于 2019-11-28 15:02:28
Joseph Fneisz

You can do it. Notice that all DNS CNAME entry point to the same host.

1: github.com/florianwolters/florianwolters.github.com

CNAME file content: blog.florianwolters.de

DNS CNAME: blog > florianwolters.github.com

2: github.com/florianwolters/pear/tree/gh-pages

CNAME file content: pear.florianwolters.de

DNS CNAME: pear > florianwolters.github.com

You can either use one CNAME resource record or one A resource record together with GitHub Pages.

So, in conclusion one have to decide:

  • Either you use example.org and www.example.org (replace the existing A record with 204.232.175.78) ...
  • ... or a subdomain, e.g. blog.example.org (create a new CNAME record with <username>.github.com).

Now, you have to choose how-to map from one (sub)domain to another:

  • If using the first you can use redirects by utilizing HTTP headers from the desired subdomain(s) to example.org.
  • If using the latter you have to use header redirects from example.org and www.example.org to the desired subdomain(s).

Also, see GitHub Pages Help for help and my GitHub Pages repository for an example CNAME file.

Edit: GitHub Pages added a detailed page that describes how-to set up a custom domain here.

You can only have one CNAME resource record for a page (both user pages and project pages) defined in the CNAME file in the root of a Git repository.

You can circumvent this by creating a CNAME record for your host(pear) in your DNS settings pointing to florianwolters.github.com, and making a entry in your CNAME file in repository for pear.florianwolters.de

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!