重新路由node.js应用程序(Ghost)



我有Ghost博客平台通过iisnode在IIS中运行。

我希望IIS将默认路径重定向/重写为这样的/tag/sometag/,这样当有人进入博客时,网站就会显示标签下的第一篇文章。

换句话说,我想要http://myblog.com/相当于http://myblog.com/tag/sometag/.

诀窍是Ghost是一个node.js应用程序,所以我已经有了一个重写规则来让Ghost处理请求。规则是这样的:

因此,所有请求都由index.js端点传递和处理。

我现在真的不知道如何做到这一点,到目前为止,我还没有找到可以帮助我的东西

提前感谢您的帮助/

我看不到你的规则,但我认为这就是你想要的。

在/ghost/core/server/routes/frontend.js内更改:

router.get('/', frontend.homepage);

router.get('/', frontend.newfunction);

然后在/aghost/core/server/controllers/frontend.js中:之后

frontendControllers = {

添加:

newfunction: function(req, res, next) {
    return res.redirect(config.paths.subdir+'/[the path]/[you want]/')
},

最新更新