How to fix minimise redirects

Photo by Paweł Czerwiński on Unsplash

As a conscientious site owner you no doubt work regularly on speeding up your WordPress site. At least, you should!

If you do, you’ll be familiar with Pingdom’s speed testing tool.

One of the common and trickier insights from that test is the Minimise redirects problem.

minimise redirects

I’ll explain what causes this problem and the steps that will fix it forever …

What Causes A Minimise Redirects Error?

A redirect happens when a page on your site causes another page to load instead. 

There are some common reasons for redirects on your site, both accidental and deliberate.

SSL certificate

Redirecting https:// to https:// 

Non-WWW (or vice-versa)

Redirecting www.yoursite.com to yoursite.com (without the www subdomain) 

Updated Post

Maybe the URL of the page has changed e.g. if you changed a post title or changed how your permalinks are builtMaybe you have an old post that’s outdated and you rewrite a newer version of that post.

You may want to redirect the old post to the new one. This way you keep the SEO benefits of the old page and give visitors the newer, more relevant information on the new page.

For these redirects, many active sites use a redirect plugin like Redirection. https://wordpress.org/plugins/redirection/With these plugins you intentionally direct a browser from one page on the site to another. 

WordPress’ “Smart” redirect

WordPress itself also has some redirection built in. e.g. On my site I have a page at https://wpstrands.com/about/faq. If someone types this URL incorrectly as https:/wpstrands/faq, WordPress is smart enough to cause a redirect to the correct URL.

Site Changes

Another way a redirect can happen is when you make some structural changes to your site. Maybe you’ve added an SSL certificate or rename the site. Your database can accidentally contain some old URLs, so redirects will be needed for the correct page to load.

Poorly formed links

Another example of an unintentional redirect is if you create links on your page or post (or a custom menu item) to your site using an incorrect URL. E.g. to https:// instead of to https://.

Each of these links need to be redirected to the correct URL version.

Are Redirects good?

Any of these redirects could have been set up by you, your developer or by a plugin you have installed on your site.

These redirects can be a good thing, of course, but it’s important to know that they do have an effect on your page load time.

An example

Lets take a look at the result of a Pingdom test on this site, WPStrands. My site uses SSL and I’ve set it up to be at the address without the leading www, i.e. at https://wpstrands.com

The site can be reached by any of these URLS:

  • https://wpstrands.com
  • https://wpstrands.com
  • https://wpstrands.com
  • https://wpstrands.com

If I run a pingdom test for https://wpstrands.com, this is the result:

pingdom test good url

Not too bad! Further down the test results page we can see the files that are loaded:

pingdom test good url files

Note that it loads the site in one go, no redirects.

Now look what happens if I run the test on my site using the URL https://wpstrands.com

pingdom test bad urlThat’s a bit slower, and there are even a few extra requests!  What happened?

The answer is revealed further down in the file requests section …

pingdom test bad url files

This time, you can clearly see that the URL given is redirected twice. First, from the http version to the https version of the site. Secondly, that URL then redirects once more to the non-www version of my site.

These redirects take time and this means a longer load time for the page. It doesn’t look much but in my case above, this is an increase in page loading time of 17%!

Now that won’t have much impact on this fast site.

But on a larger, slower site it can make a huge difference in how your visitors experience your load time. And, of course, in how Google rates your site.

Your loading time can be as much as 60% longer with these additional redirects!

Check your site-level redirects

A good tool to help you see your site redirects is this one. Just enter your URL and hit go. The Goal is to have no more than one redirect, no matter what the inputted URL is.

How to fix it

On the webserver

On most WordPress hosting, Apache is the web server running your site. Adding redirects to your .htaccess file will solve the problem of redirects like http to https and www to non-www. 

E.g. to redirect www to non-www, you need this rule.

RewriteEngine OnRewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]

Consult your host to find out exactly what rule you need to add and where.

(On more advanced hosting, you might be using NGINX as a web server, in which case you won’t have a .htaccess file. Again, you’ll need to contact your host to make the redirects.)

In the database

Just to make sure, you should also check your database for errors.

You can do this directly in your database, but that’s prone to error.

You can run a script on your database but that’s very technical and also prone to error.

The easiest way to solve this is with a plugin like Better search replace. You can run a search and do a dry run (making no changes) to see if there are any incorrect URLs still lurking in the databse.

Creating Links

Finally, get into good habits when creating links on your site. Use the proper prefix HTTP or HTTPS, use the proper subdomain www if your site uses it and include the entire path to any pages in the link.

Conclusion

Now your site should be faster and you should have one less Pingdom problem. 

Redirects are sometimes needed but they do slow down your site.  Use them correctly to minimise their speed impact and you won’t have any problems with Pingdom or other speed testing scores.

Did you have any problems with the above? Let me know in the discussion …

3 thoughts on “How to fix minimise redirects”

Comments are closed.