# connect-file-exists-or-rewrite

> Connect middleware that checks if a file exists at the location specified through the URL path, and if not rewrites the URL to e.g. '/'.

Latest version **0.1.0** (published 2014-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install connect-file-exists-or-rewrite
pnpm add connect-file-exists-or-rewrite
yarn add connect-file-exists-or-rewrite
bun add connect-file-exists-or-rewrite
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2014-01-10 |
| First published | 2014-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Philipp Bosch |
| Maintainers | philippbosch |
| Keywords | connect, middleware, file, static, rewrite |

## Links

- npm: https://www.npmjs.com/package/connect-file-exists-or-rewrite
- Repository: https://github.com/philippbosch/connect-file-exists-or-rewrite
- Issues: https://github.com/philippbosch/connect-file-exists-or-rewrite/issues
- npm.io page: https://npm.io/package/connect-file-exists-or-rewrite

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2014-01-10

## README

connect-file-exists-or-rewrite
==============================

Connect middleware that checks if a file exists at the location specified
through the URL path, and if not rewrites the URL to e.g. '/'.

Only makes sense if used together with
[Connect Static](http://www.senchalabs.org/connect/static.html) middleware.


Installation
------------

    npm install connect-file-exists-or-rewrite --save-dev


Usage
-----

    app.use(require('connect-file-exists-or-rewrite')(__dirname + '/public'));
    app.use(connect.static(__dirname + '/public'));


Assuming this directory structure …

    + public
    |
    +--- index.html
    |
    +--+ images
       |
       +--- logo.png

… requests would be treated as follows:

- `http://yourserver.com/`: untouched
- `http://yourserver.com/images/logo.png`: untouched
- `http://yourserver.com/products`: rewritten to `/`


License
-------

[MIT](http://philippbosch.mit-license.org/)

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