1
处理nodejs和表达子域的最佳做法是什么?表达式和子域名(无静态文件)
每个subsomain不会静态文件等的index.html等,但纯的代码和逻辑
var express = require('express'),
http = require('http');
var app = express();
app.set('port', 8080);
app.set('case sensitive routing', true);
// Catch api.localhost
app.get('/*', function(request, response){
/*
Other logic
*/
response.end('API');
});
// Catch www.localhost
app.get('/*', function(request, response){
/*
Other logic
*/
response.end('WEB');
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port '+app.get('port'));
});
我已经在这里回答了一个类似的问题:http://stackoverflow.com/questions/5791260/how-can-i-configure-multiple-sub-domains-in-express-js-or-connect-js/23324995 #23324995 – bmullan91