– Check HTTP/HTTPS & www/non-www redirects

Why bother?

In short, you'll want these things

  • Your site works for all four URL versions.
  • People find your site in search engines.
  • Your site is fast and does not waste resources.

Let's take a closer look at each of them.

Supporting all four URL versions

This is an absolute baseline requirement for every website. Users will type your domain with or without www, and users will put http:// or https:// in front of your domain.

In any case, your website should eventually serve the user with the requested page.

Be found

In the last paragraph, I said eventually because your site should ideally not stupidly respond with the requested page for each URL variant. Instead, it should only do so if a user's browser requests the page's so-called canonical URL. For all non-canonical URLs that refer to the same page, your website should redirect the user's browser to the canonical address of the requested resource through HTTP.

Configuring your webserver, your CMS, or whatever to redirect appropriately is beyond the scope of this article.

Anyway, how is choosing a canonical URL format important for search engines?

Technically, example.com and www.example.com are two different domains. Albeit pretty rare, it is viable that both domains serve different content as well. Hence, search engines have no guarantee that both example.com and www.example.com are the same website.

Thus, search engines need to view them as two different sites, although they are most likely the same. This distinction usually affects search engine rankings negatively cause search engines could spread stuff like link equity across multiple versions of the same page.

Example

Let's go a bit deeper here and suppose that example.com is indeed your website. A friend's website references yours and places a link to https://www.example.com/about. Another friend's website also links to the same page, but uses the non-www format http://example.com/about. A search engine crawls your friends' sites and notes the two links. When your website responds with the requested page in both cases (i.e. website does not redirect to one or the other), the following could happen: The search engine distributes the number of incoming links, two in this case, among the two versions of the page. That means, https://example.com would have one incoming link, and https://www.example.com would get assigned the other.

The result is a lower rank in the search engine index.

However, if example.com behaves nicely and redirects to its preferred URL format, the about page would get assigned both incoming links, which in turn influences search engine rankings positively.

www vs. non-www

Whether you should choose www or non-www is beyond this discussion. Ideally, you have already decided on your canonical URL format when you reach this tool. However, if you need help, here's a good starting point on MDN.

Moreover, it should be clear these days that websites should enforce HTTPS.

Correct status code for redirects

Before we go on, let's quickly talk about using the correct status codes. You will want to use 301, not 302, 303, or anything else. While all redirect codes appear to do the same for the end-user, they differ semantically. In other words, they tell HTTP clients like search engine crawlers different things.

Be fast and don't waste resources

Finally, let's discuss the third reason for checking redirects.

It's pretty clear that people prefer fast sites. Thus, it is best if your website initiates as few redirects as possible. When users request your site with a non-canonical URL, only one redirect is needed to redirect to the canonical version.

If your site needs more than one redirect per non-canonical form, there's room for improvement because each additional redirect requires a browser to send and wait for another request, making your site visitors wait longer ultimately.

Do your redirects work? Check now!