Created
April 25, 2011 03:31
-
-
Save polotek/940119 to your computer and use it in GitHub Desktop.
Testing 301 redirects with node
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
| var http = require('http'); | |
| var server = http.createServer(function (req, resp) { | |
| if(req.url.match('redir')) { | |
| resp.writeHead(301, {'Location':'http://google.com/', 'Expires': (new Date).toGMTString()}); | |
| resp.end(); | |
| } else { | |
| resp.writeHead(200, {'content-type': 'text/plain', 'content-length':4}); | |
| resp.end('Main'); | |
| } | |
| }); | |
| server.listen(8081); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment