Simple no-www redirection as connect middleware
JavaScript
Pull request Compare This branch is 4 commits behind vincentwoo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
index.js
package.json

README.md

connect-no-www

Connect middleware to redirect clients from www.yourhost.com to yourhost.com

Usage:

npm install connect-no-www

nowww = require('connect-no-www');
nowww(secure); // returns middlware, true if https, false or optional otherwise

Example:

var connect = require('connect')
  , nowww = require('connect-no-www')
  , fs = require('fs')
  , options = {
      key: fs.readFileSync('ryans-key.pem'),
      cert: fs.readFileSync('ryans-cert.pem')
    };

// https
connect.createServer(options, 
  nowww(true)
).listen(443);

// http
connect.createServer(
  nowww(false)
).listen(80);