Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

301 redirect for site hosted at github?

Here's a Github repository of mine: https://github.com/n1k0/casperjs

There's a gh-pages branch to hold the project documentation, which is basically the project website: https://github.com/n1k0/casperjs/tree/gh-pages

This branch setups the documentation site at http://n1k0.github.com/casperjs/ — hurray.

In the meanwhile, I've bough the casperjs.org domain to get this website available through it, so I put a CNAME file as recommended in the docs: https://github.com/n1k0/casperjs/blob/gh-pages/CNAME — in their example, the operation is supposed to create redirects from www.example.com and charlie.github.com to example.com

While the website now points to http://casperjs.org/, there's no 301 redirect from http://n1k0.github.com/casperjs/ (the old site url) to the new domain name.

Any idea how to setup such a redirect, if it's even possible? Is it a bug? If it is, where should I open an issue?

like image 369
NiKo Avatar asked Feb 14 '12 12:02

NiKo


People also ask

How do I redirect a git repository?

In your local repo add the new repo at github as origin ( git remote add origin https://github.com/my_user/my_user.github.io ). Push local repo to the remote ( git push -u origin master ). Wait a few minutes until Github updates Pages — for the first push it usually takes 10-15 minutes.

Can you 301 redirect to another domain?

A 301 redirect is a permanent redirect from one URL to another. While they can redirect site page URLs, they can also redirect from one domain to another.


2 Answers

Bringing this topic back from the dead to mention that GH now supports redirect-from's redirect-to parameter https://github.com/jekyll/jekyll-redirect-from#redirect-to

Simply add this to your _config.yml

gems:   - jekyll-redirect-from 

And this to the top of your index page.

--- redirect_to: "http://example.com" --- 
like image 52
Perry Avatar answered Sep 22 '22 12:09

Perry


To avoid the duplicate content, in a first time you can add a meta canonical like this:

<link rel="canonical" href="http://casperjs.org"> 
like image 22
piouPiouM Avatar answered Sep 23 '22 12:09

piouPiouM