Your Domain Name: Do You www or Not?

We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

In the early days of the web it was imperative to publish your web address with a ‘www’ prefix. Those three characters prevented confusion; it was more obvious you meant a web domain.

But is the ‘www’ necessary in 2017?

The web is prolific and few organizations opt to publish their URL with a preceding ‘www’. People understand that Google.com, Facebook.com, Twitter.com and SitePoint.com are websites. The dot-something top-level domain (TLD) such as ‘.com’ makes this more obvious but, even without it, the web is normally the first point of call for anyone looking for a company or service.

The Case For ‘www’

The ‘www’ prefix has not been deprecated. It’s unambiguous, technically accurate and distinguishes the address from similar URLs for protocols such as mail or FTP.

While a web address may be identifiable from it’s .com or country-specific prefix, hundreds of top-level domain options have been introduced in the past few years. If you’re using a less recognisable or ambiguous TLD, such as mysite.ninja, adding a ‘www’ will help avoid any doubt.

Without the ‘www’, you must set your root (non-www) domain DNS A-record to point at your web server’s IP address. This can be too rigid if you encounter availability or performance issues; the A-record is fixed and can take a day or two for changes to propagate. A ‘www’ sub-domain can be configured using a DNS CNAME record which can be updated and changed instantly.

You also need to be cautious of cookie and client-side storage. A cookie, sessionStorage, or localStorage value set for a non-www domain is shared throughout all sub-domains. If your primary website — mysite.com — sets 10Kb of cookie data, it’ll be transmitted with every request and response for app.mysite.com whether that application uses the data or not.

Finally, the ‘www’ prefix is essential in applications such as email clients and word processors which transform text to links.

The Case For No ‘www’

Despite the technical issues raised above, using a non-www domain is rarely a problem unless you have complex hosting or application requirements. Root addresses are easier to read, quicker to type and fit easier in smaller (mobile) browser interfaces. The address is more likely to work your next tweet without having to use a URL shortener.

Few people will be confused — especially when many use the Google search box rather than the browser address bar.

It’s Mostly a Vanity Thing

Some domain names look better and more balanced with the ‘www’, e.g.

  • www.google.com
  • www.facebook.com
  • www.bbc.co.uk

Some look better without:

  • twitter.com
  • yahoo.com
  • wikipedia.org

Some appear to work well in either orientation:

  • sitepoint.com / www.sitepoint.com
  • amazon.com / www.amazon.com
  • dropbox.com / www.dropbox.com

Choose whichever suits your domain but…

Configure It Wisely

Users may or may not add a ‘www’ so ensure both the www and non-www address works when a browser request is made. This can be achieved in serveral ways but the easiest option can be a web server configuration setting.

The following code in configures Apache to redirect all non-www requests to the www version of the URL. Add it to a .htaccess file in your web root:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Alternatively, this .htaccess redirects all www requests to the non-www URL:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This allows you to publicise the ‘www’ domain in documents or emails even if it’s not required.

You should also be wary if your site is served over secure HTTPS. SSL certificates are often valid for both the non-www and www domain but there’s no guarantee. Check with your Certificate Authority — it may be necessary to purchase an additional or wildcard certificate if you have the wrong one. Some hosting providers, like our partner SiteGround, let you order an SSL certificate that will work with your domain with or without the www prefix.

Finally, make a decision and stick with it. Never switch between non-www and www URLs on a whim! The .htaccess code above issues a `301 Moved Permanently` HTTP redirect code so browsers and search engines update their indexes accordingly. It can take time for changes to disseminate; users could encounter access problems while that occurs.

Did your company opt to use or drop the ‘www’? Was it a success? Did anyone notice?!

We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now