Skip to content

Instantly share code, notes, and snippets.

@chandlerkent
Created July 9, 2011 15:41
Show Gist options
  • Save chandlerkent/1073678 to your computer and use it in GitHub Desktop.
Save chandlerkent/1073678 to your computer and use it in GitHub Desktop.
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