Created
July 9, 2011 15:41
-
-
Save chandlerkent/1073678 to your computer and use it in GitHub Desktop.
This file contains 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 express = require("express"); | |
var WEBROOT = path.join(path.dirname(__filename), "../client"); | |
var app = express.createServer(); | |
app.listen(3333); | |
var publicServer = express.static(path.join(WEBROOT + "/public")); | |
app.configure(function() { | |
app.use(express.logger({ | |
format: ":method :url" | |
})); | |
app.use(app.router); | |
app.use(publicServer); | |
}); | |
// rewrite URLs and then serve: | |
// /1073678 -> / (works) | |
// /1073678/ -> / (does not work) | |
app.get("/:id([0-9]+)/?", function(req, res, next) { | |
req.url = req.url.replace(id, ""); | |
publicServer(req, res); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment