Human
Human

Reputation: 11

GitHub Pages site - redirect from www

I have github pages site. For example mysite.github.io. When I open www.mysite.github.io it doesn't work. I want both of them to work.

Is it possible to redirect www.mysite.github.io to mysite.github.io?

[EDIT]

  1. I use free github account.

  2. For more information read About GitHub Pages >> Types of GitHub Pages sites.

Upvotes: 1

Views: 268

Answers (2)

user
user

Reputation: 1070

What @daman-arora said is correct, that to redirect to mysite.com from www.mysite.com,but at first you will need to buy a custom domain.

 But I want to say that you still can redirect from www.mysite.github.io to mysite.github.io by this simple trick:

  1. Create a new repository named www.mysite.github.io.

    GitHub repository named 'www.mysite.github.io'
  2. Then create an index.html file.
  3. And then put the redirection code in the file:

<meta http-equiv="refresh" content="0; url=https://mysite.github.io">


Problems of redirection:

  • Very old browsers might not redirect to the page you want.
  • And if you use JavaScript redirection on your page, then it will not be redirected if JavaScript is disabled in users device.

    Solution:
     You can add "<a href="https://mysite.github.io">Please click here if you are not redirected</a>" to your page, so that users can click on the link and can go to the site, if not redirected automatically.

Upvotes: 0

Daman Arora
Daman Arora

Reputation: 2267

Well, to the best of my knowledge, that's not possible. Only github can do that if they want to. I don't think that it's in our hand to make this redirect. It simply throws a 404.

Instead of doing this, consider buying a custom domain from a domain registrar. After that, you'll probably be able to redirect from www.example.com to example.com

You can go for godaddy, hostgator or any other domain registrar if you want to buy a domain for your project.

Upvotes: 3

Related Questions