ST。 如果已经在请求中提供,则跳过URI的“path”部分

我的st实例configuration

var mount = st({ path: './app/', url: '/', // defaults to path option index: 'index.html', cache: { fd: none, content: none } }); 

所以当我发送请求res/img/1.jpg它去./app/res/img/1.jpg这非常清楚。 但是如果对app/res/img/1.jpg有一些要求,那么它会把这个请求redirect到./app/app/res/img/1.jpg ,当然也不会find任何东西,因为我有不同的文件结构。

是否有可能configurationst或者可能添加一些自定义代码来跳过path添加,如果它已经存在于URI中? 或者,也许有可能以某种方式添加处理不同的特定path,如一些排除?

我不知道是否可以直接用st来做,但是如果遇到某些情况,你可以添加代码来重写url。

广告代码

 var exceptions = { 'wrong_path':'right_path' } function rewriteUrl(req){ if(exceptions[req.url]){ req.url = exceptions[req.url]; } } 

然后在st方法调用之前调用该函数

 http.createServer(function (req, res) { rewriteUrl(req); mount(req, res); }).listen(1234);