No commit activity in last 3 years
No release in over 3 years
For Heroku users who want to systematically remove or add `www` from their host names. So that you have only one host which is better for SEO.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

I can live with or without WWW... – Bono from U2

WithOrWithoutWWW

This Rack middleware is ridiculously simple. It just add or remove www from your host name depending on what you want. This is good for SEO to gather everything under one host name.

Normally, this is done in your vhost settings, which means that this middleware is for when you don't have access to vhosts settings like on Heroku for example.

Install it:

sudo gem install with-or-without-www

Require it in your Rackup file:

require 'with_or_without_www'

Use it:

use WithOrWithoutWWW

And then it adds www if somebody tries to reach the website without it. Whereas:

use WithOrWithoutWWW, false

Will do the opposite. It will remove the www from your host name.

A third argument can be passed and is an array with domain names to exclude (on which the middleware will have no effect). The default value is ['localhost'].

I almost feel guilty to make a Gem for that.

Thx for reading, Mig