【问题标题】:rerouting node.js application (Ghost)重新路由 node.js 应用程序(Ghost)
【发布时间】:2015-02-28 01:49:36
【问题描述】:

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

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

换句话说,我希望http://myblog.com/ 等同于http://myblog.com/tag/sometag/

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

所以所有的请求都由 index.js 端点传递和处理。

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

提前感谢您的帮助/

【问题讨论】:

    标签: node.js iis ghost-blog iisnode


    【解决方案1】:

    我看不到你的规则,但我认为这就是你要找的。​​p>

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

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

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

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

    frontendControllers = {
    

    添加:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-18
      相关资源
      最近更新 更多