The most frequent bugs on websites: redirects

We analyzed 10 sites listed in our group’s subscriber profiles. It was an analysis of 25 potential bugs that have the biggest impact on website speed and SEO. Despite the fact that we checked for the most dangerous bugs, on average we found 9 of them. And just 2 out of 10 sites had less than 7. If you would like to see your own personal audit – you can send us a private message on LinkedIn. Right now we’re going to describe some general trends.

We will start redirecting the site. Of the 10 sites checked, 4 had a redirect related error.

Why do I need a site redirect?

A single page on a site may have different URLs:

   https://site.com/blog

   http://www.site.com/blog/

   http://www.site.com/blog

There are 8 possible variants in total. Technically, these are all different pages and even different sites. The same domain with https and http can be two completely different sites and the lack of redirects can lead your users to an invalid site. Search engines will split the weight of your page across all address variations and consequently it will appear significantly lower in search results than it could. To avoid this, you must:

   ● Select a canonical address, for example https://site.com/blog/ (protocol https, without www, and with / at the end)

   ● Configure a 301 redirect from all addresses to the canonical one

How to set up a 301 redirect on the server

The settings may vary depending on the server. You are most likely using apache and the configuration takes place in the .htaccess file. You can easily find many instructions, but keep in mind that sequential redirects are usually described there. For example, first http is replaced with https, then the www is removed. Each redirect is a new request from the user to the site. Almost no one has a one-time redirect configured – immediately http is replaced with https and www is removed. But the situation often reaches the point of absurdity. For example:

The user enters the address https://site.com/blog and the server needs to add / at the end. The server does a redirect, but it says that you need to add / and go to the address with a slash at the end and www at the beginning. Then the second redirect is triggered, for which the www needs to be removed, but it can replace https with http and a third redirect will have to fix that. It’s easy to loop this process and the site will stop working altogether. But instead of one redirection, there are usually 2-4. This happens on most sites and does not positively affect server load and search engine rankings.

 

How to set up a 301 redirect in php

Most modern sites are written in php. This language allows for programmatic redirection.

Pros:

    You can easily check all the conditions and do everything within one redirect

Cons:

   With some server settings, if the protocol is incorrect (https or http), the php will not even start and will not be able to redirect

   Most CMS’s do not have a ready functionality for this and it is not very easy to implement 

Overall, setting up redirects is not a very difficult task, but it is very important . It often needlessly gets neglected. Your programmer will select and implement the most suitable redirection option for your site within a few hours. And the testers can check even faster if everything is working correctly for all versions of the address. In the end, you will improve your position in the search results and reduce the load on the server.