1
如果我想建立.../whatever/stuff
被靜態地提供,而是作爲http://example.com/mystuff
引用的目錄中,我試着這樣做:如何使用任意啓動路徑在Express中設置靜態服務?
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錯誤。這對於目錄列表來說尤其有問題,因爲目錄中間件不會在指向子目錄的鏈接上放置結尾的斜槓。
我能做些什麼來解決這個問題嗎? (是我的語法上面是否正確?)
看起來像一個連接問題。您應該創建一個小測試場景並通過https://github.com/senchalabs/connect –