Created
January 30, 2014 04:31
-
-
Save joeyblake/8702676 to your computer and use it in GitHub Desktop.
Multiple 301 redirects in Ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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