将 github 页面重定向到不同的 url

Redirect github page to different url

我已将我的存储库从 foo 更改为 bar 。所以 github 页面 url 自动从 /foo 更改为 /bar 但我想要 /foo 也重定向到 /bar。 我怎样才能做到这一点?

我正在使用自定义域,但我认为这没有任何区别。

重命名存储库时似乎GitHubdoesn't redirect the pages:

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

我认为您仍然可以通过向 ritz078.github.io 项目添加页面来进行重定向。创建 embed-js.html 使用:

---
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">

重新创建 embed-js 存储库

gh-pages branch 添加一个 index.html 文件,其中包含:

<!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>

但这只会重定向来自 http://rkritesh.in/embed-js/ 的流量,其他页面如 http://rkritesh.in/embed-js/anypage/ 将收到 404 错误。

参考: