jekyll - GitHub Pages Jekyll 使用 application/octet-stream 作为内容类型进行重定向

标签 jekyll redirect github-pages

我已经在 github 页面上实现了重定向,但由于某种原因,您的服务器为重定向页面返回“application/octet-stream”内容类型。这会导致浏览器无法呈现重定向页面,因此生成的 JavaScript 无法执行以实际执行重定向。

如何让响应 header 将 text/html 指定为内容类型,以便重定向工作?

这是网址。

http://www.pknopf.com/blog/performance-ccli-vs-com

这是回复。

HTTP/1.1 200 OK
Server: GitHub.com
Content-Type: application/octet-stream
Last-Modified: Sat, 06 Sep 2014 04:30:37 GMT
Expires: Sat, 06 Sep 2014 04:41:33 GMT
Cache-Control: max-age=600
Content-Length: 598
Accept-Ranges: bytes
Date: Sat, 06 Sep 2014 04:40:38 GMT
Via: 1.1 varnish
Age: 545
Connection: keep-alive
X-Served-By: cache-iad2132-IAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1409978438.779912,VS0,VE2
Vary: Accept-Encoding


      <!DOCTYPE html>
      <meta charset=utf-8>
      <title>Redirecting...</title>
      <link rel=canonical href="http://www.pknopf.com/development/2013/03/07/Performance-CPP-CLI-vs-COM.html">
      <meta http-equiv=refresh content="0; url=http://www.pknopf.com/development/2013/03/07/Performance-CPP-CLI-vs-COM.html">
      <h1>Redirecting...</h1>
      <a href="http://www.pknopf.com/development/2013/03/07/Performance-CPP-CLI-vs-COM.html">Click here if you are not redirected.</a>
      <script>location='http://www.pknopf.com/development/2013/03/07/Performance-CPP-CLI-vs-COM.html'</script>

最佳答案

jekyll redirect from documentation中所示,重定向网址需要尾部斜杠。

在您的帖子中,您必须在重定向中添加尾部斜杠。

例如:在_posts/2013-03-07-Performance-CPP-CLI-vs-COM.md

redirect_from: "/blog/performance-ccli-vs-com"

变成:

redirect_from: "/blog/performance-ccli-vs-com/"

关于jekyll - GitHub Pages Jekyll 使用 application/octet-stream 作为内容类型进行重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25704775/

相关文章:

GitHub 页面未在新创建的存储库上呈现 HTML 或 MD 文件

image - 为什么在 jekyll 网站上添加图像的 Markdown 语法不起作用?

ruby - macOS 无法安装 Jekyll Gem

ruby - 如何将已构建的 Jekyll 站点推送到 GitHub?

html - 如何自定义 Jekyll 的 url?

javascript - 如何使 Opera Javascript 保存重定向到历史记录以便history.go(-1) 工作?

ruby - 在 YAML 变量中包含 jekyll/liquid 模板数据?

ruby-on-rails - 重定向 404、422、500 Ruby On rails

javascript - redirect_uri 不属于应用程序

github - 如何在 https ://user-images. githubusercontent.com/{path}/{filename} 上托管图像?