Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Pages https/www Redirect

How can I get https://www.test.com to redirect to https://test.com when using GitHub pages to host a static website?

I recently enabled TLS (provided by GitHub/Lets Encrypt) for my static site by setting A records at my DNS provider (namecheap). I've also chosen to "Enforce HTTPS" option in my GitHub repository's settings, which handles redirecting requests from http://test.com to https://test.com. I have a redirect configured through my DNS provider which forwards http://www.test.com to https://test.com, but the one missing piece of the puzzle is forwarding https://www.test.com to https://test.com.

Regarding this issue, GitHub says, "If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar."

... and my DNS provider says, "It is not possible to set up a URL redirect in the account for the TCP port forwarding from http://www.domain.tld (uses port 80) to https://www.domain.tld (working via port 443)."

I seem to be caught in an infinite loop of the two services saying the other should provide this functionality.

like image 720
pdoherty926 Avatar asked Feb 21 '19 22:02

pdoherty926


People also ask

How do I redirect http to GitHub Pages?

On GitHub, navigate to your site's repository. Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Pages. Under "GitHub Pages," select Enforce HTTPS.

Does GitHub Pages support SSL?

GitHub Pages has supported custom domains since 2009, and sites on the *. github.io domain have supported HTTPS since 2016. Today, custom domains on GitHub Pages are gaining support for HTTPS as well, meaning over a million GitHub Pages sites will be served over HTTPS.

How do I redirect a GitHub repository?

html ; add and commit. Login to Github in browser; create a new repository my_user.github.io . In your local repo add the new repo at github as origin ( git remote add origin https://github.com/my_user/my_user.github.io ). Push local repo to the remote ( git push -u origin master ).


1 Answers

What worked for me:

  • Change your custom domain to be prefixed with www., like this: form

  • Save the settings and wait until www.example.com resolves and works.

  • Remove the www. prefix and save again.

  • Wait for browser and DNS caches to invalidate.

  • All combinations should lead to https://example.com/ and no SSL error should appear.

like image 167
Paul Avatar answered Sep 29 '22 04:09

Paul