Multiple GitHub Pages and custom domains via DNS

前端 未结 3 2035
悲&欢浪女
悲&欢浪女 2020-12-22 15:29

I want to have one user page and multiple project pages hosted by GitHub Pages but available under ONE custom domain (with subdomains for each GitHub Pages

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 16:03

    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 .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.

提交回复
热议问题