Jekyll可以根据URL参数投放内容吗? [英] Can Jekyll serve content based on a URL parameter?
问题描述
我正在将博客从WordPress迁移到GitHub页面.在我网站的日志中,我注意到有很多这样的请求:
I'm migrating a blog from WordPress to GitHub pages. In the logs for my site, I've noticed that there are many requests like this:
GET /wp/?feed=atom
此301重定向到该网站的ATOM供稿.
This 301 redirects to the ATOM feed for the site.
我计划使用httrack
刮我的网站并迁移所有静态内容.但这是一个问题.有什么方法可以使用Jekyll复制/wp/?foo=bar
重定向吗?
I'd planned to use httrack
to scrape my site and migrate all the static content. But this presents a problem. Is there any way to replicate the /wp/?foo=bar
redirects using Jekyll?
推荐答案
您可以使用 Jekyll redirect_from插件,这是可以在github页面上使用的罕见插件之一.
You can use Jekyll redirect_from plugin which is one of the rare plugin that can be used on github pages.
唯一的问题是,从服务器的角度来看,yoursite.github.io/wp/?foo=bar
是yoursite.github.io/wp/index.php?foo=bar
.因此,任何?foo=bar
都将解析为同一文件.
The only problem is that yoursite.github.io/wp/?foo=bar
from the server point of view is yoursite.github.io/wp/index.php?foo=bar
. So, any ?foo=bar
is resolved to the same file.
我只有您的xml feed可以重定向,这可以解决问题:
I you have only your xml feed to redirect, this does the trick :
---
layout: null
redirect_from:
- /wp/
---
content ...
如果您要重定向多个文件,则必须从wp/index.html
文件切换到javascript解决方案.
If you have multiple files to redirect, you will have to switch to a javascript solution from a wp/index.html
file.
这篇关于Jekyll可以根据URL参数投放内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!