From c76711314adf504426344d170b256a1e566c8d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 4 Sep 2014 17:31:18 +0200 Subject: [PATCH] Redirect www to non-www for SEO --- server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server.js b/server.js index 66fbff7..9ce354c 100644 --- a/server.js +++ b/server.js @@ -22,6 +22,15 @@ app.use(compress()); app.use(bodyParser.urlencoded({ extended: false })); +// Redirect www.yellowlab.tools to yellowlab.tools (for SEO) +app.all('*', function(req, res, next) { + if (req.hostname.match(/^www\.yellowlab\.tools/) !== null ) { + res.redirect('http://' + req.hostname.replace(/^www\.yellowlab\.tools/, 'yellowlab.tools') + req.url); + } else { + next(); + } +}) + // Routes definition app.get('/', indexController); app.post('/launchTest', function(req, res) { launchTestController(req, res, testQueue); });