【问题标题】:Grunt Connect requires .html extensionGrunt Connect 需要 .html 扩展名
【发布时间】:2014-02-21 17:57:25
【问题描述】:

我一直在用 Grunt 和 grunt-contrib-connect 构建一个站点。

我希望我的网站网址不需要文件扩展名(即“foo”而不是“foo.html”)
据我所知,gunt-contrib-connect 不关注 htaccess 文件,因此我无法在那里定义 mod 重写。

这似乎可以通过使用中间件来实现,但我找不到任何关于这如何可能的提及。任何帮助将不胜感激。

    connect: {
        server: {
            options: {
                port: 9000,
                base: 'build/',
                livereload: true,
                open: true
            }
        }
    },

【问题讨论】:

    标签: node.js gruntjs grunt-contrib-connect


    【解决方案1】:

    根据connect documentation,需要connect中间件实现重写规则。

    grunt-connect-rewrite 似乎是要走的路,您可以在这里找到更多信息:https://github.com/viart/grunt-connect-rewrite

    这是使用前面提到的实现的完全相同的问题。

    Removing file extension using grunt-contrib-connect and grunt-connect-rewrite

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      相关资源
      最近更新 更多