Posted in Code on September 3rd, 2014

Force HTTPS with Github Pages

After mucking about in the Disqus admin panel for too long, I realized that the reason that certain comments on the site were showing up in the panel but not on the site was that Disqus (perhaps rightfully) sees a single page via two different protocols as... two different pages. That's right, comments left on http://site.com/some-post won't show on https://site.com/some-post.

For now, the only way around it for GitHub Pages seems to be some javascript hackery forcing all pages to use HTTPS (desirable even without the comment issue):


<script>
    var host = 'coderabbi.github.io';
    if (window.location.host == host && window.location.protocol != 'https:') { 
        window.location.protocol = 'https:';
    }
</script>