I have a github pages site, and I want to add it as a subdomain to my cloudflare domain without using a page rule
1 Answer
This can easily be done by adding a few settings to CloudFlare and then later GitHub.
7 Steps on adding a subdomain to CloudFlare
- Login to Cloudflare
- 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.
- Click the DNS icon at the top of the screen.
- Select
CNAME
using the drop-down options - Add the sub domain in
NAME
- E.g
my-project
- E.g
- Add your unqiue GitHub username domain in
Domain name
.- E.g
your-gibhub-username.github.io
- E.g
- 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
- Login to GitHub.
- Under 'Your repositories', select your Project.
- On your Project Repository Toolbar find and click 'Settings'.
- Scroll down to section 'GitHub Pages' and select the correct branch.
- A new field will be enabled called
Custom domain
, simply add the sub domain to this field.- E.g
my-project.example.com
.
- E.g
- 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 think its not working because GitHub is redirecting when accessing
your-username.github.io
May 1, 2017 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 fromapcoder123.github.io
toapcoder123.github.com
and see if that works. May 1, 2017 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. May 1, 2017 at 14:55