0.1.0 • Published 12 years ago
connect-file-exists-or-rewrite v0.1.0
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 middleware.
Installation
npm install connect-file-exists-or-rewrite --save-devUsage
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/: untouchedhttp://yourserver.com/images/logo.png: untouchedhttp://yourserver.com/products: rewritten to/
License
0.1.0
12 years ago