This blog is hosted on my own domain, ever since the start I’ve supported finding my site as lowtek.ca or www.lowtek.ca.
WordPress allows you to do some simple URL rewriting to push people to whatever you want, and I had configured things to push visitors to www.lowtek.ca/roo since the ‘www’ seemed like the right thing to do. I never really thought much about it until I came across no-www.org.
No-www.org strives to make the Internet and communications about it as fruitful as possible. To that end, we make the modest proposal that website makers configure their main sites to be accessible by domain.com as well as www.domain.com.
This makes a lot of sense, and any site that supports they consider a Class A site. They define a further level of no-www support as Class B, and consider this optimal no-www compliance level. There is also Class C, but is not recommended.
Thus lowtek.ca has been a Class A compliant no-www site all along. However just the other day I switched things around to be Class B – allowing both www.lowtek.ca and lowtek.ca to work, but redirecting people who visit www.lowtek.ca to simply lowtek.ca. I had two reasons that motivated me: 1) lowtek.ca is shorter 2) I’m working on getting a SSL certificate and having the short name allows me to reuse it for other things (like mail) if I want.
To make the change I needed to address a couple of things. First step was to go to all of the wordpress blogs I host and change the General Settings to make sure wordpress wasn’t going to try to rewrite the URL to have a www prefix. Failure to do this will result in a broken site as you get a rewrite/redirect loop.
Next I had to do battle with my apache configuration. This is something I’m sure would be easier if I was a better web server admin. I ended up adding the rewrite rules to the sites-available definition(s) I use, one for normal HTTP and the other for HTTPS. Many suggest using .htaccess but I would rather this was codified in my actual apache config files.
The no-www.org FAQ has a rewrite rule, but I ended up using
RewriteCond %{HTTP_HOST} ^www.lowtek.ca$ [NC]
RewriteRule ^(.*)$ http://lowtek.ca$1 [R=301,L]
The [NC] specifies ‘no case’, ie: case insensitive. The R=301 specifies that we’re redirecting, and the HTTP code is 301 ‘Moved Permanently‘. The L indicates this is the last rule, as you can have multiples.
Now my domain validates with no-www.org as a Class B implementation.
There is a downside to the no-www movement, but only for larger sites. This is likely why Google continues to have a www prefix. Cookies that are set from domain.com can be read by anything.domain.com. For small sites like mine, this has no impact, for larger sites it could be a problem.