redirects

Express/Connect middleware for segment-able url redirects


Keywords
superstatic, redirects, 301, static, divshot
License
MIT
Install
npm install redirects@1.1.1

Documentation

redirects

Express/Connect middleware for segment-able url redirects

Install

npm install redirects --save

Usage

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) {

});

Usage Options

Basic redirect

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) {

});

Redirect with custom status code

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) {

});

Segmented value redirect

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) {

});

Run Tests

npm install
npm test