expressNakedRedirect is a middleware for Express that redirects naked(root domain) request to www or its reverse.
$ npm install express-naked-redirect --save
- Redirect naked(root domain, non-www) request to www.
- Redirect www request to naked(root domain, non-www).
- Redirect naked(root domain, non-www) request to specific subdomain.
- Redirect specific subdomain request to naked(root domain, non-www).
It allows you to redirect http://domain.tld to http://www.domain.tld
app.use(require('express-naked-redirect')())
It allows you to redirect http://www.domain.tld to http://domain.tld
app.use(require('express-naked-redirect')(true))
It allows you to redirect http://domain.tld to http://sub.domain.tld
app.use(require('express-naked-redirect')('sub'))
It allows you to redirect http://sub.domain.tld to http://domain.tld
app.use(require('express-naked-redirect')(true, 'sub'))