2012-11-17 54 views
3

我想在node.sj和Expressjs v3的子域中添加,但我一直在嘗試加載子域時404無法獲取/。在nodejs中添加子域並表示

var express = require('express'), 
    app = module.exports = express(), 
    MongoStore = require('connect-mongodb'), 
    server = require('http').createServer(app), 
    fs = require('fs'), 
    socket = require('./lib/sockets'), 
    flash = require('./middleware/flash'); 

app.configure('development', function() { 
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
}); 

app.configure('production', function() { 
    app.use(express.errorHandler()); 
}); 

app.configure(function() { 
    app.use(express.favicon(__dirname + '/public/domain.com/images/favicon.ico')); 
    app.engine('.html', require('ejs').__express); 
    app.set('views', __dirname + '/views/site'); 
    app.set('view engine', 'ejs'); 
    app.use(express.cookieParser()); 
    app.use(express.bodyParser()); 
    app.use(express.methodOverride()); 
    app.use(flash()); 
    app.use(app.router); 
    app.use(express.vhost(app.get('manager_vhost'), require('./subdomains/Manager'))); 

}); 

server.listen(3000); 
socket.listen(server, sessionStore, app); 

這是我在我Manager文件

var express = require('express'), 
    manager = module.exports = express(); 


manager.configure(function() { 
    manager.use(express.static(manager.get('base_location') + '/public/')); 
    manager.engine('.html', require('ejs').__express); 
    manager.set('view engine', 'ejs'); 
    manager.set('version', version); 
}); 

有什麼我做錯了嗎?

回答

2

您的路線在哪裏定義?嘗試添加一個路線,看看會發生什麼

manager.get('/', function (req, res) { 
    res.render('layout', { 
     title: 'Manager ' 
    }); 
}); 
+0

哇我覺得啞巴..thx我忘了添加任何控制器! –