I want to redirect my ghost aplication everytime it matches www.url to url. I've found this two-years post and tried to update the code. I inserted this snippet before the fist router.get (Admin routes), but it doesn't work. What is the correct way to do this? Ghost version is 0.7.4.
// 301 redirect from www to non-www
router.get('/*', function(req, res) {
if(req.headers.host.match(/^www/) !== null) redirect301(res, 'http://' + req.headers.host.replace(/^www\./, '') + req.url);
});