0

I have changed my repo from foo to bar . So automatically the github page url changed from /foo to /bar but i want that /foo also redirects to /bar. How can I achieve this ?

I am using a custom domain but I don't think that makes any difference.

ritz078
  • 2,193
  • 3
  • 22
  • 24

2 Answers2

3

It seems GitHub doesn't redirect the pages when renaming repository:

GitHub Pages sites are not automatically redirected when their repositories are renamed at this time.

I think you can still make a redirect by adding a page to your ritz078.github.io project. Create embed-js.html with:

---
permalink: /embed-js/
---

<!DOCTYPE html>
<meta charset=utf-8>
<title>Redirecting...</title>
<link rel=canonical href="http://rkritesh.in/embed.js/index.html">
<meta http-equiv=refresh content="0; url=http://rkritesh.in/embed.js/index.html">
svlasov
  • 9,923
  • 2
  • 38
  • 39
  • Mine is a normal static website. How do I convert it to this. I have already done what's written https://github.com/ritz078/embed.js/tree/gh-pages . What else should I do ? My old repo name was **embed-js** . Now it is **embed.js** – ritz078 Mar 28 '15 at 15:04
  • Actually redirect works, http://rkritesh.in/embed.js/embed-js -> http://rkritesh.in/embed.js Try `redirect_from: "/../embed-js"`. – svlasov Mar 28 '15 at 15:23
  • Got a reply from github that this feature is currently not supported. – ritz078 Mar 29 '15 at 08:43
1

Recreate an embed-js repository

In the gh-pages branch add an index.html file that contains:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=http://rkritesh.in/embed.js/">
        <script type="text/javascript">
            window.location.href = "http://rkritesh.in/embed.js/"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow the <a href='http://rkritesh.in/embed.js/'>link to example</a>
    </body>
</html>

But this will only redirect the traffic from http://rkritesh.in/embed-js/ other page like http://rkritesh.in/embed-js/anypage/ will get a 404 error.

reference : https://stackoverflow.com/a/5411601/1548376

Community
  • 1
  • 1
David Jacquel
  • 51,670
  • 6
  • 121
  • 147