Pointing subdomains to github pages

github, github-pages, redirect, subdomain

Solution

Aliasing domain names is done by replacing the A records for {blog,astrid}.craftworkgames.com with CNAME records that point to `username.github.io`. Then, so that Github knows how to redirect from each of your custom domains, you add a special "CNAME" file to your repos, where the contents are exactly the domain name you want to redirect from (in your case, "astrid.craftworkgames.com").

Example

I setup `githubp.gjp.cc` with a CNAME record to `gpittarelli.github.io`. I then created the repo gpittarelli.github.io with an index.html and a CNAME file that includes exactly `githubp.gjp.cc`.

You can see it in action at: http://githubp.gjp.cc/ This behaves exactly how you want `blog.craftworkgames.com` to behave. Note that if you try to go to `gpittarelli.github.io`, github redirects to my custom subdomain.

The setup is almost exactly the same for a project page, except the index.html and CNAME files are made on a gh-pages branch. You can see an example at: http://githubp-reddit.gjp.cc/

Which is based off the `gh-pages` branch of this repo:

https://github.com/gpittarelli/reddit-twitch-bot/tree/gh-pages

Sources

- https://help.github.com/articles/setting-up-a-custom-domain-with-github-pages/

- https://help.github.com/articles/adding-a-cname-file-to-your-repository/

- https://help.github.com/articles/about-custom-domains-for-github-pages-sites/#apex-domains

Problem

I have a situation. Currently I have two different websites hosted at the following domains. The sites are currently hosted on Azure (although that shouldn't be relevant to this question). ``` blog.craftworkgames.com astrid.craftworkgames.com ``` I would like to move them to github pages hosting instead. I've been working on the new pages at the following URLs. ``` craftworkgames.github.io craftworkgames.github.io/Astrid.Framework ``` The first one hosts the blog and the second one hosts Astrid respectively. Ultimately I would like to keep my existing URLs and point them to the new domains but from what I understand, it's going to be difficult to point the astrid.craftworkgames.com domain to the Astrid.Framework subfolder on github pages. The other thing that bothers me about my situation is that the URL is case sensitive. For example, craftworkgames.github.io/astrid.framework gives a 404 error. I feel like this is going to be problematic when handing out the URL. So, my question is, what options to I have? Can I somehow point `astrid.craftworkgames.com` to `craftworkgames.github.io/Astrid.Framework` transparently. Or, alternately, can I use an alias like `www.craftworkgames.com/astrid` that's easier to remember and type. Thanks.

Original source