www and non-www recommendations
Should we use www in front of our domains, or is non-www better? This article can hopefully help you decide.

By. Jacob
Edited: 2025-08-29 13:36

The www part of a URL is simply a subdomain. It stands for World Wide Web and is an optional part of server configuration. Many websites no longer use it, as it is often considered unnecessary.
Websites that do not use the www subdomain typically redirect it to the cleaner example.com version of their site. This is partly because some users still type "www" when visiting a website, and without a redirect, those users might encounter a 404 Not Found error.
The www subdomain has historically been used alongside other subdomains like the pop or imap subdomains for mail servers, and the ftp subdomain for FTP services. Administrators would point each of these subdomains to its corresponding service. While this isn’t usually relevant to end users, some companies adopted the www prefix in their marketing.
Recommendation
It is recommended that web developers redirect users to either the www or non-www version of their site — whichever they choose. The non-www version is generally preferred, as "www" adds no real value to users and requires extra typing.
Under some circumstances, the www subdomain is used to more clearly separate and isolate services, especially to avoid unintentionally sending cookies with HTTP requests for subdomains. E.g. When storing images on a subdomain like images.example.com subdomain, it would be redundant and wasteful to include cookies on every HTTP request.
Although it is possible to avoid the problem by using the proper syntax when assigning cookies, some code or JavaScript outside of your control might still assign cookies incorrectly, causing cookies to become "globally" available on all your subdomains. To avoid dealing with this, you could just host your site on the www subdomain. I'd personally still use the bare domain, and possibly opt for hosting images on another domain entirely, if this becomes a problem.
Redirecting your www subdomain
Redirecting the www subdomain can be done in several ways. One method is to use an .htaccess
file; another is to configure your CMS to handle the redirect. However, not all CMS platforms support this out of the box. You might need to search for a plugin that enables it.
When using an .htaccess
file to perform the redirect, you only need to create a file called .htaccess in a text editor and place it in your server root. Then, include the following content in the file:
RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^example\.com RewriteRule (.*) http://example.com/$1 [R=301,L]
Note: Replace example.com
with your own domain name.
Tell us what you think: