我已经在 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/