How to transfer HTTPS traffic to a new domain with GitHub Pages
I’m not saying it’s a good idea, but sometimes it’s necessary.
The problem
I wanted to move my professional site from brownanalytics.com to kmcelwee.com and redirect traffic, but GoDaddy does not support HTTPS ➡️ HTTPS redirects. I could use GoDaddy’s redirect service, but anyone who went to an HTTPS link (say https://www.brownanalytics.com/fortune-100-blm-report/site/) would get the scary “Your connection is not private” message, saying my website may be trying to steal their information. The browser, seeing that the user was going to an invalid HTTPS site, would warn them that their connection was not secure. If the user accepts the risk and moves on, they’d be redirected as expected, but this, of course, is not the behavior we want.
The (hacky) solution
You could spin up a DigitalOcean droplet, configure an Apache server, and set up SSL certificates exclusively for redirecting the domain. That could cost upwards of $50–60/year. If you’d prefer a simpler, free option, you may want to use GitHub Pages’ infrastructure.
By overwriting 404.html
and implementing a custom domain, (view how to configure a custom domain with GitHub Pages), you can make sure that any traffic that goes to a your old domain passes through this webpage. From there, you can redirect as necessary.
I wrote some simple JavaScript to dynamically edit the metadata tags so that any subpage of brownanalytics.com could redirected to the corresponding subpage of kmcelwee.com. In case the metadata redirect doesn’t work, there’s some secondary JavaScript to provide a link where the user can redirect manually.
Don’t @ me (but please @ me)
While this all “works”, I have trouble believing this is the best solution to my problem. I expect this will hurt SEO, and I’m waiting for unintended side-effects. Thankfully, this duct-tape approach is sufficient for what I need right now. But I can’t be the first to have this issue, which makes me surprised that Googling for other solutions came up empty-handed. Am I missing something obvious? Please let me know!
Questions? Comments? Contact me and see more projects on my website (with a new domain 🙂)