Skip to content

Instantly share code, notes, and snippets.

@joeyblake
Created January 30, 2014 04:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joeyblake/8702676 to your computer and use it in GitHub Desktop.
Save joeyblake/8702676 to your computer and use it in GitHub Desktop.
Multiple 301 redirects in Ghost
server.get('/*', function(req, res, next) {
var fullURL = req.protocol + "://" + req.get('host') + req.url;
//your 301 redirects
var redirects_301 = {
'http://thinkingandmaking.com/working/92/72-questions-to-ask-on-your-first-day': '/view/72-questions-to-ask-on-your-first-day',
'http://thinkingandmaking.com/working/92/someother': '/view/someother'
}
//check and see if there is a redirect, if so, redirect to it!
if (redirects_301[fullURL]) {
res.redirect(301, redirects_301[fullURL]);
} else {
//otherwise continue on
next();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment