I recently bought a domain from 1and1. I then redirected it to my GitHub page, (e.g., http://example.com to https://foo.github.io) using 1and1's Domain Center (see the screenshot below):

enter image description here

Now I need to redirect my domain from http://example.com to https://example.com so that HTTPS will redirect to my GitHub page. How can this be done?

  • OP is asking that how can he redirect his http version of domain to https? Please unhold this question, and I can answer (although I am in an Airport loo)
    – DavChana
    Commented Dec 7, 2016 at 22:45
  • 1
    @DavChana Since you demonstrated in your edit (sorry, questions can't be edited with comments or answers) that you understand this, I edited to clarify it based on the comments and reopened it so you can take a stab at it.
    – dan
    Commented Dec 7, 2016 at 23:25
  • @foo We could still use some clarifications: were you able to redirect HTTP to GitHub, but HTTPS didn't work? If HTTP worked, did you specify that under "Redirect destination" instead of HTTPS (like you have in the screenshot)? Please clarify what worked and did not work..
    – dan
    Commented Dec 7, 2016 at 23:34
  • @foo did you ever setup SSL Certificate or keys for example.com in github or 1&1's system?
    – DavChana
    Commented Dec 8, 2016 at 0:06

1 Answer 1


This is what I understand:

You have a github page foo.github.io

Your domain example.com is redirected to foo.github.io via an A Record with github-provided IP Address. By this, when using URL example.com, the address bar shows example.com, but data is from foo.github.io. Essentially, example.com & foo.github.io show same page.

Now, github's nature is that it supports both http and https; means if you request http on example.com, it will serve http://example.com, and if you request https, it will serve https://example.com (provided your SSL certificate keys are there in github).

What you are asking is that no matter if http was requested or https, only https should always be served.

Now, in dynamic languages and servers like ASP.NET or PHP or LAMP, it would be done server side, but as github support only static html javasçipt css files only, your only option is to use a javascript location.href.replace by detecting if protocol is http, redirect to https.

As I am on mobile and about to board a flight, I will quote javascript code from s similar question's this answer:

if (location.protocol != 'https:')
      location.href = 'https:' + window.location.href.substring(window.location.protocol.length);

Note: If you have never setup SSL Private and public keys for example.com in 1&1's system, it means you first need to do that, otherwise when https://example.com will be requested, browsers will show an error. I will add some steps for that when I am back from vacation..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.