【发布时间】:2018-01-22 10:09:52
【问题描述】:
我创建了一个 Jekyll 站点,托管在 Netlify,地址为 old.address.com。现在我想重定向到new.address.com。但是 Netlify 文档似乎不起作用,或者我不理解这些文档。这就是我所做的:
我添加了 _config.yml:(因为 Netlify 说 Jekyll 排除了 '_...' 文件)
include:
- _redirects
我添加了一个_redirects 文件。我只是将 Netlify 生成的指令复制粘贴到该文件中,这是内容:
# Redirect domain aliases to primary domain
https://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
https://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
这没有任何效果。 有什么问题/我做错了什么?
目录如下所示:
$ ls -1
404.html
about.md
_config.yml
Gemfile
_includes
index.md
_layouts
_posts
_redirects <—— added as per Netlify's instructions
_sass
_site
$ ls -1 _posts/
2018-01-01-like-about-jekyll.markdown
2018-01-02-installation-instructions.markdown
2018-01-02-kind-creatures.markdown
配置文件只是默认的:
title: ...
email: ...
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: ...
github_username: ...
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
talkyard_comments_server_url: ...
include:
- _redirects
请注意,虽然上面有相当多的细节,都是各种默认的东西。所以它不是特定于我的问题。它应该适用于所有新的 Jekyll 网站。
【问题讨论】:
-
_redirects的内容是什么? -
@marcanuy 这是上面第二个最上面的代码 sn-p,以
# Redirect domain aliases ...开头的那个(我编辑了这个问题以使其更清楚一点)。 -
注意:
include: ["_redirects"]将覆盖默认设置include: [".htaccess"]。要确保.htaccess也包含在 Jekyll 构建中,请使用include: [".htaccess", "_redirects"]