Redirecting GitHub Pages to HTTPS with Cloudflare

/ / 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 does not redirect to To overcome this, you can go to Cloudflare’s Page Rules page for which everyone is given 3 free page rules.

Click the Create Page Rule button, write your website URL (e.g.*) 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.$1) in the destination URL textfield.

After clicking Save and Deploy, visits to will be redirected to

The picture below shows how it has been setup to redirect all HTTP traffic to HTTPS for any page on

Cloudflare Page Rules setup

This will of course also work with websites hosted anywhere else, such as the Google Cloud Platform, AWS, etc.