Configuring a “preferred” domain is probably one of the most common questions I’ve seen during my years as a WordPress and SEO consult, and it’s also one of the most poorly executed by website owners and web developers alike.
The first step here is to understand all the possible variations of a given domain:
…that is, there should be a total of 4 variations for most TLDs, which include 2 HTTP variations and 2 HTTPS variations, with a “www” and “non-www” version for both of these protocols, respectively.
Without getting into too much discussion in this post about which variation is best for which situation, suffice it to say that your company or team needs to decide on a clear “preferred” domain a.k.a. “canonical domain” in some circles.
After you have chosen which variation you prefer, it is important to not change your mind — at least, not too often. The reason is that each of these variations can be seen as a different website domain by companies such as Google who carefully track the reputation, backlinks, and so forth of web properties. Plus, there is the issue of all the links pointing to your website, along with traffic analytics, static resource URLs, and more to worry about. Therefore, changing your preferred domain should be an extremely thoughtful decision, and one that you do NOT change more than once, ideally.
Now comes the fun part (heh). After your are SURE about which domain variation you want to keep as your primary domain, you need to update your CMS (WordPress) and database settings accordingly.
Firstly (and more importantly) you should update your “Site URL” and “WordPress URL” as required:
Next, you should scan and replace all instances of the 3 “undesired” variations across your entire MySQL database, and replace them with your preferred variation. Yes, that means that you need to run a minimum of 3 “search and replace” SQL queries. The easiest way to do this is with a plugin, such as Better Search Replace.
After this stage, you have truly cleaned up your domain situation, however, we aren’t done yet…
Here is where things get a little dicey, because there are so many conflicting recommendations out there. In general, I strongly recommend NEVER using a WordPress plugin or any other application-level script (i.e. PHP) to perform 301 redirects in regard to your TLD. In other words, you should only use plugins (etc) to redirect URIs that come AFTER the TLD, such as a page slug.
Rather, dealing with protocol redirects (HTTP + HTTPS) or subdomain / naked domain (www vs. non-www) should take place on the server level, and/or on the DNS level, to make sure for security, stability, speed, and SEO reasons that the 301 redirect is completely solid and cannot be circumvented in the case of an application break down.
If you are using Nginx, our recommended server block rules make this step very easy. If you are using Apache, the most common method is via htaccess although you can also do this directly in your Virtual Host settings.
Lastly, for good measure, you can also perform a permanent 301 redirect at the DNS level by using a free tool such as CloudFlare. Using their Page Rules feature, you can simply introduce a “rule” for each of the 3 undesired domain variations mentioned above, and 301 redirect these along with wildcard variables to your preferred domain variation. In this way, you have a double layer of 301 redirects for your website, making it all but impossible for hackers, bots, or anything else to find its way into one of your undesired domain variations!
NOTE: if you are a LittleBizzy client, all the above is included for just $40 SSL setup!
Tags: 301, CloudFlare, DNS, HTTP, HTTPS, Redirects, Servers, SSLLast modified: 20 Apr, 2016https://www.littlebizzy.com/?p=9394
"After being hosted on GoDaddy for years, I didn't realize how negatively it was impacting my search traffic. Soon after moving to LittleBizzy, my homepage went from page 3 on Google to #1 world-wide for my target market, and I also reached the top 3 on Google Maps, with no additional SEO work."Juliette S.
"Before moving to LittleBizzy, whenever our news website was featured on the Drudge Report, it often slowed to a crawl or even froze up during big traffic spikes. Now, that never happens anymore, and we've been able to focus on publishing more articles instead of worrying about our web hosting."Tony H.
"The research by Amazon is definitely true, because our slow WooCommerce store was bleeding sales. After LittleBizzy stabilized our performance and moved us closer to our target customers, we saw a measurable improvement in shopping cart checkouts, esp. during holidays... much better!"Mohammed H.
No contracts, free migration, and free SSL forever. What are you waiting for? Order Hosting Now.
WordPress Gossip, Technical SEO News, And Other Goodies.
Free. Unsubscribe anytime.