Ditch the www Subdomain

It’s time

We’re in the year 2014, people know what the world wide web is (and have known for quite some time), yet may organisations still insist on using a www subdomain for their primary website instead of a pretty subdomain-less url.

Keep it simple

I don’t use, link to, or promote the url www.ilee.co.uk - I always use ilee.co.uk. It’s prettier, simpler and still obviously a url.

Use a permanent (301) redirect

I do redirect www.ilee.co.uk to ilee.co.uk, for completeness and SEO reasons. Serving the same content for each url could be considered duplicate content without a redirect. GitHub pages automatically handles this and it’s GitHub’s preferred format (you’ll never see www.github.com, it’s always github.com).

Expressjs

To my horror I realised yesterday that www.plugreg.com, didn’t redirect to plugreg.com. plugreg is written in node.js and uses the expressjs framework, so I wrote a handy little function to handle the www redirect scenario:

1
2
3
4
5
6
7
8
9
10
11
var redirect = function (req, res, next) {
var baseUrl = req.protocol + "://" + req.host,
wwwUrl = req.protocol + "://www.";
if (baseUrl.substring(0, wwwUrl.length) === wwwUrl) {
res.redirect(301, baseUrl.replace("://www.", "://") + req.url);
} else {
next();
}
};
app.all("*", redirect);

Configure webmaster tools

Under “site settings” of Google Webmaster Tools, you also have the option to set your preferred domain:

  • Don’t set a preferred domain
  • Display URLs as www.ilee.co.uk
  • Display URLs as ilee.co.uk

Here’s to a www-less 2014.