我想创建一个主页,目前来看,我认为Github的页面功能可以满足我的需求。但是,以后我可能会想要切换到更完整的CMS /博客引擎。
如果我决定将我的主页移动到其他地方,并保留所有旧的URI,是否可以从Github页面提供永久重定向(HTTP 301)?
我想创建一个主页,目前来看,我认为Github的页面功能可以满足我的需求。但是,以后我可能会想要切换到更完整的CMS /博客引擎。
如果我决定将我的主页移动到其他地方,并保留所有旧的URI,是否可以从Github页面提供永久重定向(HTTP 301)?
meta
解决方案很丑陋,但如果它足够好地愚弄谷歌,我可能会尝试一下。 - Fred Foo大规模重定向布局技术
有关单个页面重定向的内容,请参见:https://dev59.com/m2ox5IYBdhLWcg3wVC1y#36846720 实际的301似乎是不可能的。
如果您想进行大规模重定向:
http://you.github.io/some/path
到:
http://new_domain.com/some/path
_layouts/default.html
: the default layout
_config
uses the default layout:
defaults:
-
scope:
path: ''
values:
layout: 'default'
离开后
create _layouts/redirect.html
with an HTML redirect derived from Redirect from an HTML page along:
{% assign redir_to = site.new_domain | append: page.url %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel="canonical" href="{{ redir_to }}"/>
<meta http-equiv="refresh" content="0;url={{ redir_to }}" />
</head>
<body>
<h1>Redirecting...</h1>
<a href="{{ redir_to }}">Click here if you are not redirected.<a>
<script></script>
</body>
</html>
_config
contains:
defaults:
-
scope:
path: ''
values:
layout: 'redirect'
new_domain: 'http://new-domain.com/some/path
replace every non-default layout with a symlink to the redirect
layout. This is the only ugly part of this technique. I don't see a beautiful non-plugin solution.
是的,可以。简而言之,通过在GitHub Pages设置中设置自定义域名来设置CNAME重定向。
通常情况下,当您希望通过自定义域名提供GitHub Pages服务时(比如说用户尝试访问https://kamarada.github.io/,然后浏览器重定向到https://linuxkamarada.com/,但实际上页面仍托管在GitHub上),就需要这样做。
但是,在您先前使用GitHub Pages提供网站服务并转移到其他服务器(例如GitLab Pages)时,也可以使用此方法(我想这对于WordPress等网站也适用)。
请查看这个答案:用户试图访问https://kamarada.github.io/,然后浏览器会被重定向到https://linuxkamarada.com/,但实际上页面位于GitLab上。
you.github.io/some/path
批量重定向到new_domain.com/some/path
吗?还是只需要单个重定向?我建议我们将这个用于批量重定向,因为单个重定向已经在以下链接中有所涵盖:https://dev59.com/Smkw5IYBdhLWcg3wDWIk 和 https://dev59.com/m2ox5IYBdhLWcg3wVC1y?lq=1 - Ciro Santilli OurBigBook.com