Redirecting GitHub Pages to HTTPS with Cloudflare
Updated: April 24, 2017
Your GitHub repo settings have an
Enforce HTTPS option under the GitHub Pages section, but that won’t work with custom domains. You can instead take advantage of Cloudflare’s free SSL certificate.
After configuring everything you will perhaps notice that visits to http://example.com does not redirect to https://example.com. To overcome this, you can go to Cloudflare’s Page Rules page for which everyone is given 3 free page rules.
Create Page Rule button, write your website URL (e.g.
http://example.com/*) in the first textfield, click
Add a Setting. Select
Forwarding URL setting and set Status Code to
301 - Permanent Redirect, and enter your website URL with HTTPS prefix and $1 suffix (e.g. https://example.com/$1) in the destination URL textfield.
The picture below shows how it has been setup to redirect all HTTP traffic to HTTPS for any page on maike.me: