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.

1457 views

Edited: 2018-02-25 01:18

www to non-www, redirect

The www part of URLs is really just a subdomain, it is short for World Wide Web, and an optional server configuration. Many websites are not using it, as it often considered unnecessary.

Those who do not use the www subdomain typically redirect it to the clean example.com version of their website. One reason is that some users still type "www" when they go to a website, and it would confuse those users if suddenly they got a 404 not found response.

The www subdomain has been used in combination with other subdomains, such as the pop or imap subdomains for mail servers, and ftp subdomain for FTP servers. Administrators would point each of these subdomains to each their own service. It is not really relevant for users, but some companies picked it up in their marketing of their website.

Recommendations

It is recommended that web developers simply redirect their users to one or the other. The preferred is to use the non-www version, because having www in the URL is irrelevant to users, and only requires more typing.

Redirecting your www subdomain

Redirecting the www subdomain can be done in a number of ways, one way is to use htaccess files, another is to configure the CMS system to do it, but not all CMS systems comes with this capability. You can try searching for a plugin that adds it, however.

When using htaccess files to perform the redirect, all you need to redirect incoming traffic on your www subdomain, is 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. You should replace example.com, with your own domain name.

Tell us what you think:

  1. An in-dept look at the use of headings (h1-h6) and sections in HTML pages.
  2. Pagination can be a confusing thing to get right both practically and programmatically. I have put a lot of thought into this subject, and here I am giving you a few of the ideas I have been working with.
  3. The best way to deal with a trailing question mark is probably just to make it a bad request, because it is a very odd thing to find in a request URL.
  4. How to optimize image-loading and automatically include width and height attributes on img elements with PHP.
  5. HTTP headers are not case-sensitive, so we are free to convert them to all-lowercase in our applications.

More in: Web development