Redirect Github homepage to custom homepage - github

I used to host my webpage on username.github.io.
I have now set up a new webpage on username.com, and has no relation to username.github.io.
However, I want to redirect username.github.io to username.com.
As of now, if somebody enters username.github.io, it takes you to the 404 not found page.
Is there anyway I can reroute it to username.com?

Instead of a redirect, the normal process is for your current GitHub pages to use a custom domain
You find a better illustration of that process here
Go to your GitHub Pages site’s repository settings.
Under “Custom domain”, add or remove your custom domain and click “Save”.
Setting “custom domain” creates a file named CNAME in the same repository.
Don’t delete it.
The OP sidv adds in the comments:
After setting up my website (deployed elsewhere) and the DNS servers, I was unable to open the webpage on Safari and Firefox (only on Chrome).
Finding the load balancing IP and configuring it as an A record ended up redirecting the webpage appropriately.

Related

Different custom domains for GitHub user page and project page?

Is it possible to associate more than one custom domain with the same GitHub user account? I would like to use one custom domain for my personal page and another custom domain for a project page.
Specifically, I would like www.deeplearningbook.org to show the GitHub pages for the goodfeli/book project, and www.iangoodfellow.com to show the GitHub pages for the goodfeli/goodfeli.github.io user page. (And if I can be ambitious, I'd like blog.iangoodfellow.com to show the GitHub pages for goodfeli/blog)
I have tried a few different ways to set them up, and everything I have done has ended up with one URL or the other working but not both.
My current setup is a huge mess, but since a commenter asked me what my name records currently are:
iangoodfellow.com: I deleted all name records after the last failure. namecheap filled in a default parking page thing. I deleted the custom domain field from the goodfeli/goodfeli.github.io repository on github. Strangely, http://goodfeli.github.io successfully loads but https://goodfeli.github.io redirects to the broken www.iangoodfellow.com parking page. I'm not very happy that github is doing that... I didn't realize that taking down goodfeli.github.io was a possible failure mode here.
deeplearningbook.org: I doubt this is the correct thing to do, but it's the only thing I've been able to get to work so far:
Redirect domain: deeplearningbook.org -> https://www.deeplearningbook.org
A record # 192.30.252.153
A record # 192.30.252.154
CNAME Record www goodfeli.github.io.
It's that last CNAME record that I think is the problem. Having the goodfeli.github.io CNAME record for www.deeplearningbook.org prevents me from linking a different domain to the goodfeli.github.io personal page.
I haven't been able to figure out how to link www.deeplearningbook.org specifically to the goodfeli.github.io/dlbook project page though.
Yes in short, through one sub domain exampleUser.github.io, for example, my page https://shushugah.github.io is my main one, and maps to a custom domain https://shushugah.com while https://shushugah.github.io/23 links to a different github page at https://2Jews3Opinions.com One side effect of this is that https://shushugah.com/23 also redirects to https://2Jews3Opinions.com
I detail this in my blog post https://medium.com/#shushugah/2-customs-domains-for-2-github-pages-a8a9e77d3e57

How to stop redirecting to custom domain?

Some years ago I added a custom domain from free site just to try a new feature of Github. Now that I want to make a page my main url keeps getting redirect to myexpireddomain.com ...
http://myuser.github.io => myexpireddomain.com
http://myuser.github.io/page => myexpireddomain.com/page
and this all results in 404...since domain doesn't exist.
I think I need to remove cname file somewhere. But out 20 repos that I have I don't see any that should cname... which repo is at the root domain. http://myuser.github.io
For removal of custom domain, I removed all of the text from the custom domain field in the settings for that particular website, then pressed save. Then, I found out that you have to clear the browser cache (in google chrome I just cleared all of the browsing data for the last hour), otherwise it will still redirect to the custom domain!
Also, make sure that the CNAME file in your repository is deleted. Github pages creates this for you when you add a custom domain.
The repository for your main domain is either myuser.github.io, as documented on the Pages website, or possibly myuser.github.com in case your site is from before GitHub started using github.io for Pages.
Check the master branch for a file called CNAME in the repository root.

Redirect Github Pages to custom domain

I have created a Github Pages site and put it on repository abc of github account with username xyz.
So, my site is now live on xyz.github.io/abc
I created a cname file with my custom domain, and configured my DNS with the settings said on Github pages.
Now, my site is also live on mycustomdomain.com
Now, I don't want my site to be live on xyz.github.io/abc . I want it to redirect to mycustomdomain.com or not accessible.
Is there any way to do that?
I know that I can create User Pages site (with username.github.io) which will automatically redirect to custom domain, but I want to create project site.
Any suggestions?
A CNAME solution:
Sure. Github has a nice functionality for it.
When you create CNAME folder inside of your repo, you will be redirected:
https://help.github.com/articles/adding-a-cname-file-to-your-repository/
Check out my Github Pages website: https://github.com/ondrek/ondrek.github.io
( you can browse ondrek.com, but it's impossible to browse ondrek.github.io )
A JS solution:
If you want to redirect a custom page — the only possible solution will be javascript redirection.
if (window.location.href==="https://xyz.github.io") {
window.location.href = "https://mycustomdomain.com";
}
but it will not solve your problem with Google. You can solve this with correct using Google Webmaster Tools and tell to Google about the duplicate (for SEO purposes).
I had a GitHub Pages website (https://kamarada.github.io/), I moved it to GitLab (https://kamarada.gitlab.io/) and besides that I set up a custom domain on GitLab (https://linuxkamarada.com/). Now the question: how to make a 301 redirect from the GitHub Pages to the custom domain? Is that possible?
Well, as Ciro Santilli answered on this other question, there is no "beautiful non-plugin solution". Indeed, the solution I found is not beautiful, it is more kind of a workaround, but it works.
Inspired by the Samuel Ondrek answer on this same question (thanks a lot!), I set up CNAME redirection.
Go to your GitHub Pages repo, click Settings and below GitHub Pages, under Custom domain, enter your custom domain and click Save.
Now open another tab on your browser, open DevTools (F12), select the Network tab. Try to access your GitHub Pages website and see that a 301 redirect happens.
GitHub is going to complain that your domain is not configured properly:
Well, that does not really matter. What matters is that you have the 301 redirect required by the Google Search Console's Change of Address Tool and your website won't lose its Google ranking.
This might be a bit old but I'd still like to give an alternative answer to this. You can simply use meta refresh on your index.html
<meta http-equiv="refresh" content="1;url=http://example.com/" />
Then use a regular link (an a message also) on the page in case refresh stops. Though it is not recommended for SEO since google might index the blank page. But it would most likely work work.
You could use JavaScript to inspect the domain of the current page and redirect if necessary. If you go this route, the question and answer are already on SO:
Redirection based on URL - JavaScript

Can not host a webpage on Github

I have a javascript and html snake game and I want to host it on github I do All the steps and make a gh-pages But I get this error 404 File not found ?when I search Username.github.io/repository-name
Any idea why and how I can fix it? Should I wait for github email After I do the commands??
Most web servers have a "default" page, e.g. index.html, that will be shown when the user doesn't request a particular page. GitHub Pages is no different.
Your repository contains a single file called snakeGame.html, which works just fine if you request it. Unfortunately, GitHub Pages doesn't know that this page should be shown by default. As far as it knows that file has no special meaning.
To get your page to show up at http://peggykh.github.io/Snake/ instead of http://peggykh.github.io/Snake/snakeGame.html, you should rename your file to index.html.

How can I redirect a request to a subdomain to another subdomain on Route 53?

I have a GitHub Pages Jekyll blog at blog.Antrikshy.com. I have been meaning to move it to code.Antrikshy.com for a while now. I made the new address a CNAME for antrikshy.github.io on Amazon and wired everything correctly to make it work. Now my blog.Antrikshy.com URL is broken. How can I set it to redirect it to the new subdomain?
I'm new to this. Comment if you want any more information.
Preferably I'd like to do a 301 redirect and also retain the entire path, but that's not very important. I just want it to work, even if it means that users are redirected to the new home page.
You could accomplish this with s3 website redirect[1].
create a new s3 bucket with the name blog.antrikshy.com
enable s3 website
create an alias to blog.antrikshy.com bucket
enable redirects on your website
you can create redirects per page as well by creating a key for each page or redirect everything to your homepage
http://aws.amazon.com/about-aws/whats-new/2012/10/04/web-page-redirects-on-amazon-s3-hosted-websites/