我们说,我在http://shawn.arthur.io/
安装了幽灵博客。
我没有创建多个博客,而是制作了一个博客并利用了"标签"用于分隔不同的集合。
> http://shawn.arthur.io/en/tag/travel
> http://shawn.arthur.io/en/tag/culture
> http://shawn.arthur.io/en/tag/food
我发现修改鬼后端几乎是不可能的。我可以在nginx ghost配置文件中添加重写规则,当您实际访问http://shawn.arthur.io/en/tag/$X
http://shawn.arthur.io/en/blogs/$X
的内容
以下是我的nginx代码:
location /en {
proxy_pass http://localhost:2368;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
location /en/blogs {
proxy_pass http://localhost:2368/en/tag;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering on;
}
问题
当我写http://shawn.arthur.io/en/blogs/sklfasjfask时,它工作正常,但当我通过链接访问网页时,它会自动重定向到http://shawn.arthur.io/en/tag/sklfasjfask。为什么会这样?我该如何解决?
答案 0 :(得分:1)
您可以通过添加包含/en/tag
语句的另一个location
块来有效地屏蔽rewrite
前缀。例如:
location /en/tag {
rewrite ^/en/tag(.*)$ /en/blogs$1 permanent;
}
答案 1 :(得分:1)
就我个人而言,我会让Ghost为您做到这一点。 https://docs.ghost.org/tutorials/implementing-redirects/
注意,我刚刚意识到我会在2019年做出响应,而您在2017年提出了这个要求。也许Ghost当时没有内置此功能。无论我的回答是否有助于他人,我都在回答。