3

I have a github pages site, and I want to add it as a subdomain to my cloudflare domain without using a page rule

4

This can easily be done by adding a few settings to CloudFlare and then later GitHub.

7 Steps on adding a subdomain to CloudFlare

  1. Login to Cloudflare
  2. Use the drop-down menu in the upper left of your screen and click your domain that you want the redirect to take place on.
  3. Click the DNS icon at the top of the screen.
  4. Select CNAME using the drop-down options
  5. Add the sub domain in NAME
    • E.g my-project
  6. Add your unqiue GitHub username domain in Domain name.
    • E.g your-gibhub-username.github.io
  7. Leave TTL as automatic and CloudFlare enabled, click Add Record button.

5 Steps on setting up GitHub Pages to use your custom sub domain for your Repository

  1. Login to GitHub.
  2. Under 'Your repositories', select your Project.
  3. On your Project Repository Toolbar find and click 'Settings'.
  4. Scroll down to section 'GitHub Pages' and select the correct branch.
  5. A new field will be enabled called Custom domain, simply add the sub domain to this field.
    • E.g my-project.example.com.
  6. Finally click the Save button.

DONE!

There is no need to enter a URL paths as the virtual host file hosted by GitHub will handle this part for you.

  • I've done all of those steps, but when going to alexa.arunpattni.com i get ERR_NAME_NOT_RESOLVED imgur.com/V6roVXm imgur.com/x0BkQ4D – Arun P May 1 '17 at 14:35
  • I think its not working because GitHub is redirecting when accessing your-username.github.io – Simon Hayter May 1 '17 at 14:41
  • Think I know why... I think the Repository you made is a little old and before the time when GitHub started using .io, in the CNAME field on Cloudflare change it from apcoder123.github.io to apcoder123.github.com and see if that works. – Simon Hayter May 1 '17 at 14:51
  • Or it could be because you've named the repository apcoder123.github.io, which I don't advise on. You could fork it and try a different repository name. – Simon Hayter May 1 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.