【发布时间】:2012-09-30 06:31:52
【问题描述】:
如果我想将目录.../whatever/stuff 设置为静态服务,但引用为http://example.com/mystuff,我尝试这样做:
app.configure(function() {
app.use('/mystuff', _express.static(__dirname + "/whatever/stuff"));
app.use('/mystuff', _express.directory(__dirname + "/whatever/stuff"));
});
这大部分有效,但如果我引用 mystuff 的子目录而没有尾部斜杠,比如 http://example.com/mystuff/subdir,它会重定向到错误的位置 (http://example.com/subdir/),从而导致 404。这个目录列表尤其成问题,因为目录中间件不会在指向子目录的链接上放置斜杠。
我可以做些什么来解决这个问题吗? (我上面的语法正确吗?)
【问题讨论】:
-
看起来像一个连接问题。您应该创建一个小测试场景并在github.com/senchalabs/connect 提交错误
标签: node.js express node.js-connect