Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Created August 31, 2012 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanepiper/a01ae972d25231ad59e7 to your computer and use it in GitHub Desktop.
Save tanepiper/a01ae972d25231ad59e7 to your computer and use it in GitHub Desktop.
server.mount(function(req) {
if ( !req.headers['x-forwarded-for'] && /\/s.gif|\/s.json/.test(req.url) === true ) {
return true;
}
return false;
}, function(req, bounce) {
var subdomains = /(www\.|count\.)/;
var matches = req.headers.host.match(subdomains);
var host;
if (matches) {
host = req.headers.host.replace(matches[1], '');
} else {
host = req.headers.host;
}
var url = host + '/pb' + req.url;
bounce(url);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment