永久重定向github gh页面
-
24-10-2019 - |
题
我想创建一个主页,目前,我认为Github的页面功能将满足我的需求。但是,稍后,我可能想切换到更全面的CMS/博客引擎。
如果我决定在保留所有旧的URI的同时,可以从GitHub页面上提供永久重定向(HTTP 301)的永久重定向(HTTP 301)?
解决方案
我能推断出的最好的是,GitHub尚未添加。看 Tekkub回应2010年4月 回复:将其添加到功能请求列表中。另一个消息 一月份来自另一个用户 建议将元标记作为解决方法(可能不是一个好的解决方案)。
其他提示
对于其用户的安全性,GitHub页面不支持客户服务器配置文件,例如.htaccess或.conf。但是,使用插件的Jekyll重定向,您可以自动将访问者重定向到更新的URL。
可以在此处找到更多信息: https://help.github.com/articles/redirects-on-github-pages/
质量重定向布局技术
各个页面重定向涵盖: https://stackoverflow.com/a/36846720/895245 实际的301似乎是不可能的。
如果您想大规模重定向:
http://you.github.io/some/path
至:
http://new_domain.com/some/path
如下。
搬走之前
_layouts/default.html
: :默认布局_config
使用默认布局:defaults: - scope: path: '' values: layout: 'default'
搬走后
创造
_layouts/redirect.html
与HTML重定向衍生自 从HTML页面重定向 沿着:{% 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>location='{{ redir_to }}'</script> </body> </html>
_config
包含:defaults: - scope: path: '' values: layout: 'redirect' new_domain: 'http://new-domain.com/some/path
用符号链接替换每个非默认布局
redirect
布局。这是该技术的唯一丑陋部分。我看不到美丽的非包解决方案。
不隶属于 StackOverflow