如果我想将目录.../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.这对目录列表尤其有问题,因为目录中间件没有在子目录的链接上放置一个斜杠。
我能做些什么来解决这个问题吗? (我的语法是否正确?)
答案 0 :(得分:-1)
试试这个:
app.use('/mystuff*', ..);