Tim S
Tim S

Reputation: 2329

How do I enforce HTTPS on both my root domain and WWW subdomain on GitHub Pages?

I have set up my GitHub Pages project site to enforce HTTPS, and it works fine when I browse to http://rootdomain.com, http://www.rootdomain.com, or https://rootdomain.com — they all correctly display https://rootdomain.com.

However, when I browse to https://www.rootdomain.com, I get a browser privacy error NET::ERR_CERT_COMMON_NAME_INVALID. Is there way to make this URL redirect to https://rootdomain.com as well?

I have configured my DNS (Google Domains DNS) as follows:

DNS Configuration

My CNAME file contains rootdomain.com, and my GitHub Pages Custom Domain is set up as follows:

GitHub Pages Custom Domain Settings

Upvotes: 3

Views: 726

Answers (1)

Tim S
Tim S

Reputation: 2329

As it turns out, my DNS provider (Google Domains) has a feature to enable SSL for Subdomain Forwarding. So I removed the CNAME for my WWW subdomain and created a Subdomain Forward Synthetic Record as follows:

enter image description here

Google will create an SSL cert for the subdomain, which they say can take up to 24 hours. When I did it, it only took a couple of hours. Now https://www.rootdomain forwards to https://rootdomain as expected.

Upvotes: 2

Related Questions