Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Redirect all requests to www. subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
m7kvqbe1 committed May 18, 2015
1 parent 27884df commit e9cfac0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/index.html');
});

// Redirect to www
app.all(/.*/, function(req, res, next) {
var host = req.header("host");
if (host.match(/^www\..*/i)) {
next();
} else {
res.redirect(301, "http://www." + host);
}
});

server.listen(8080);

// WebSocket
Expand Down

0 comments on commit e9cfac0

Please sign in to comment.