Express/Connect middleware for segment-able url redirects
npm install redirects --save
var http = require('http');
var connect = require('connect');
var redirects = require('redirects');
var app = connect();
app.use(redirects({
'/some-url': '/redirected-url'
}));
http.createServer(app).listen(3000, function (err) {
});
var connect = require('connect');
var redirects = require('redirects');
var app = connect();
app.use(redirects({
'/some-url': '/redirected-url'
}));
http.createServer(app).listen(3000, function (err) {
});
var connect = require('connect');
var redirects = require('redirects');
var app = connect();
app.use(redirects({
'/some-url': {
status: 302,
url: '/redirect-url'
}
}));
http.createServer(app).listen(3000, function (err) {
});
Any value in the url that begins with a :
will be considered a segment. This segment will replace the same value in the redirect url. This usage also works like the cusotm status codes example.
var connect = require('connect');
var redirects = require('redirects');
var app = connect();
app.use(redirects({
// "/old/test/path/here" would redirect to "/new/test/path/here"
'/old/:value/path/:loc': '/new/:value/path/:loc'
}));
http.createServer(app).listen(3000, function (err) {
});
npm install
npm test