# redirects

> Express/Connect middleware for segment-able url redirects

Latest version **1.1.1** (published 2015-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install redirects
pnpm add redirects
yarn add redirects
bun add redirects
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2015-02-26 |
| First published | 2014-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Divshot |
| Maintainers | scottcorgan |
| Keywords | superstatic, redirects, 301, static, divshot |

## Links

- npm: https://www.npmjs.com/package/redirects
- Repository: git@github.com:divshot/redirects
- Homepage: https://github.com/divshot/redirects
- Issues: https://github.com/divshot/redirects/issues
- npm.io page: https://npm.io/package/redirects

## Dependencies (6)

- [toxic](https://npm.io/package/toxic.md) ^1.0.0
- [is-url](https://npm.io/package/is-url.md) ^1.2.0
- [globject](https://npm.io/package/globject.md) ^1.0.0
- [pathematics](https://npm.io/package/pathematics.md) ^0.1.1
- [glob-slasher](https://npm.io/package/glob-slasher.md) ^1.0.0
- [lodash.isobject](https://npm.io/package/lodash.isobject.md) ^3.0.0

## Recent versions

- 1.1.1 (latest) — 2015-02-26
- 1.1.0 — 2015-02-24
- 1.0.0 — 2014-11-18
- 0.2.0 — 2014-07-18

## README

# redirects

Express/Connect middleware for segment-able url redirects

## Install

```
npm install redirects --save
```

## Usage

```js
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

```js
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

```js
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.

```js
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
```

---
_Source: https://npm.io/package/redirects · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
