Which is better: www or non-www? HTTP or HTTPS? Here’s why, and how, you should set up your preferred domain.
Hopefully, I’ll be able to easily show you how to set your preferred domain url.
Did you know that there may already be a preferred version of your registered domain? (In fact, there could be more than one preferred domain option.) The question is: preferred according to who — the search engine crawlers? Other sites that link to you? Your visitors?
Those questions lead to the possibility that there may not just be one preferred version of your domain–but that there may be 2 (or even more), depending on whether you consider how your domain is set up (in your hosting settings), your incoming links, whether there are canonical tags on your pages, or what your .htaccess file may say.
If this seems a bit overwhelming, don’t worry. The topic of preferred domain format is actually very simple to understand, and there are some relatively simple methods available to allow you to set a preferred domain style.
You may have noticed that some website addresses are in the form of www.site.com and others are
non-www domains and don’t have the www in front (site.com). (This is usually known as the ‘dub-dub-dub’/www and ‘non-dub-dub-dub’/non-www url versions, respectively.)
You may also know that, in most cases, from the user’s perspective, it usually doesn’t matter if you see a dub-dub-dub or non-www version of a site.
However, from a more technical perspective, setting a preferred domain can matter.
In this article, we’ll explore why it can matter, why you may want to consciously choose a preferred domain address, which options are available, and how you can go about doing your preferred domain setting.
Preferred domains can matter for reasons ranging from the technical (how you arrange folders and subdomains on your hosting account) to user experience.
The key word in that question is consciously. As I mentioned before, there may be preferred versions of your domain, but they’re not the version that you would prefer, then you may wish to consciously choose a personal preference.
Ultimately, setting a single, preferred version of your domain can be better technically and help to consolidate the ranking power of links going to different versions of your domain.
Should you have a www before your domain name, or not?
While Secure Sockets Layer (SSL) usually doesn’t come up when talking about preferred domains, I felt that I should mention it because http (or https) is part of a website’s full address.
In case you’re not sure, HTTP means Hyper-Text Transfer Protocol. The S in HTTPS means Secure.
I think that, in the overwhelming majority of cases, HTTPS (which usually involves an SSL certificate) is preferred, because it means that any data shared between the visitor and the site is encrypted.
A lot of web hosts offer free SSL certification. SSL can also be established with some WordPress plugins or third-party services.
At this point, you hopefully have come to a decision as to whether you’ll go with the www or non-www version of your domain.
When it comes to setting a preferred domain, there are 3 options I know of. Keep in mind that these 3 can be combined:
This is the one I’d recommend above all, because it’s server-side and the changes you make with this method apply to your entire domain. (However, you can still use this with the other 2 methods, especially canonicalization.)
Technically, this method is not as much a domain-wide preference as much as it is a page-by-page preference. That said, canonicalization has benefits similar to those of setting a domain-wide preference, so it’s something worth considering.
Although the 301 redirect and canonicalization methods are probably more important, if you really want to establish a preferred domain, you should use that version everywhere you can, including in your sitemaps XML file(s).
As a side note, it used to be that you could set your preferred domain in Google Search Console (Formerly Google Webmaster Tools), but that option isn’t available anymore. That’s not a big deal, as doing this in Search Console (or in the webmaster tools area of other search engines) would only show your preferred domain to that search engine, not the rest of the Internet.
If that sounds technical, that’s because…it is. Sort of. It’s not overwhelmingly difficult, but it does involve entering code in a specific location.
If your site is a self-hosted WordPress site, I have some good news: there are at least a few plugins that can help make this easier for you. I would search in the Add New area of the Plugins section for 301, redirection, or htaccess. You should see potential plugins that can help you.
.htaccess is short for hypertext access, and without going into too much detail, it basically specifies some rules that the server should follow under certain conditions (such as, in our case, how a www or non-www request is to be handled).
You may have to go to your cPanel or file manager to find this. It’s usually on the root of the domain or installation.
Do this just in case something goes wrong. (In the following steps, you’ll be adding code to your .htaccess file, so if you later see that something’s wrong, it’ll be good to have an original file to restore.)
There are a few ways to do this. You can just copy and paste everything in your .htaccess file to NotePad or Text Edit on your computer and save it as something you’ll remember (such as .htaccess-original). You can also just duplicate the file on your server. Just remember that it’s the one named .htaccess that will be the one that the server reads.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Perhaps the best benefit of canonicalization, aside from letting search engine know which is the original version of a page, is the benefit to your link building efforts. If two sites link to different versions of a page on your site (https/http or non-www/www), canonicalization effectively consolidates the flow of link juice of those links, helping with your search engine visibility and search engine rankings.
In short, instead of your incoming linking power being diluted across different versions of your page, it’s consolidated onto one version.
(In other words, you’re hypothetically getting one definitive page with 100% linking power, rather than two pages each only having 50% linking power.)
That said, this method is simple, yet potentially tedious.
It’s simple because it only involves adding a single line of code to a web page.
It’s potentially tedious because if you don’t have a modern content management system (like WordPress, Joomla, Shopify, and the rest) or you have a lot of page variations, you might have to establish this on specific pages. If you have a lot of such pages, the volume of work can make things quite repetitive.
One good thing about this option is that you can also specify http or https versions of a web page.
The steps are:
rel=”canonical” link tag on HTML pages
OR
rel=”canonical” HTTP header
As I alluded earlier, if you have a modern content management system, there may be simple solutions that allow you to establish canonicalization throughout your site. On WordPress, this can be done by any of a number of plugins.
We also have a blog post that focuses on canonicalization and has instructions on setting canonical tags on your pages, in case you opt for this option.
If you hand-code (that is, type) your sitemaps file(s), just use the preferred version of your domain.
That said, a lot of sitemaps files are created automatically. The reason why I mention this option last is because I think the .htaccess file determines the version of the domain that’s shown in the sitemaps file. So, by using the .htaccess method, the sitemaps file (when they’re refreshed/recreated) will likely reflect the changes you made.
Hopefully, the whole notion of setting your preferred domain is a bit less intimidating. Depending on your goals, doing this can be a worthy endeavor.
Do remember that, before making changes to a files, back up that file. (Check with your host to see if they do automatic backups. I know of one that does backups every 24 hours, so if a mistake were to be made, that host could probably restore the version that was around 24 hours ago.)
Also, the methods I listed here are what I think are available to the majority of my readers. If your host’s server is different than most, or your situation calls for something customized, then do ask your technical support team for instruction.
Hopefully, you now have a better understanding of the benefits of setting a preferred domain and how to set it for your site.
Wondering what you could do to get your site to show up for your keyword in the top of search results? Check out our other SEO articles and tests for tested information to help you get to the top.