isotropic-2022
Share
Blog
Search
Menu

How To Avoid Multiple Page Redirects On Your WordPress Site

By James LePage
 on May 8, 2020
Last modified on January 6th, 2022

How To Avoid Multiple Page Redirects On Your WordPress Site

By James LePage
 on May 8, 2020
Last modified on January 6th, 2022

What Is It?

Redirects slow down your page load speed. When a browser requests wa resource that has been redirected, the server usually returns an HTTP response like this:

HTTP/1.1 301 Moved Permanently
<Location: /path/to/new/location
Code language: JavaScript (javascript)

The browser must then make another HTTP request at the new location to retrieve the resource. This additional trip across the network can delay the loading of the resource by hundreds of milliseconds. 

The best case scenario with redirection is that it triggers an extra HTTP request-response cycle, which slows down page rendering. The worst outcome would be that the redirection could bring about multiple round trip request-response cycles, including DNS lookup, TCP handshake, and TLS negotiation, which would add on seconds to your page loading time. 

Why Does It Display?

A page fails this audit when it has two or more redirects. If failed, it’ll display this Performance Opportunity section. 

The reasons that your page may have redirects varies, but there are a couple common causes: 

  • A malicious redirect code is inserted into a website with the intent of redirecting the site visitor to another website. Malicious redirects are typically inserted into a website by attackers with the intent of generating advertising impressions.
  • Using device-specific versions of your site so a mobile user is redirected from example.com to m.example.com/home
  • Hyperlinking inconsistently on your site by mixing URLs with and without the www prefix

How Do You Fix It?

It depends on the cause of your redirects. 

The first thing you need to do is identify the redirect. Then you need to figure out why it’s being called. Then you need to figure out how to fix it. 

Identifying your redirect is pretty easy. We like using Pingdom Tools, a page load test service, but you can use Chrome Dev Tools as well. With Pingdom, just enter the site and run the test. Scroll to the “Response Codes” section -- anything labeled with a 301 or 302 is a redirect. You’ll probably want to focus your efforts on the 301 redirects (which are permanent) as 302 is a temporary redirect. 

Now we need to identify what the redirect is doing and why it’s being called. If you scroll down, you’ll find a section called “File requests”. If you sort by Status Code, then deselect “Rising”, you’ll see all of your 301 and 302 redirects.

In this example, NYTimes is calling a script from Google that redirects. The resulting request-response cycle adds a total of 114ms to the loading time. 

Malicious redirects should be remedied by hiring a remediation service like WordFence, then securing your website with a security plugin. We really like both Securi and WordFence, and in most cases, the free versions of their plugins work well. 

If you’re having redirects due to multiple versions of your domain, like “www., http:// and https://”, this can be fixed pretty easily. Make your A record the naked domain pointing to your server IP address. Make the www subdomain a CNAME alias of the naked domain. This way all your traffic is directed to your naked domain, regardless of how they type in your site URL. There are no redirects and your site loads faster.

Here’s an example (we use Cloudflare to manage our DNS):

isotropic.co points to our server IP address. 

www.isotropic.co  is an alias of isotropic.co and has its traffic proxied through Cloudflare.

Then go and change the WordPress Address and Site Address in WP Admin Dashboard from www to naked domain and make sure there is no 301 redirect in your .htaccess.

It's especially important to avoid redirects in resources required for your Critical Rendering Path. That’s because redirects add loading time which impacts your critical chain (discussed in the section above this one).

If you’re redirecting to a mobile version of your site, you should consider redoing your site to be mobile responsive, meaning there’s one version of your site that adapts its design (through conditional CSS classes) to match the screen size, instead of multiple versions of the site. Not only does this help fix your redirects issue, but it also boosts SEO and user experience.

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic, a WordPress education company and digital agency. He is also the founder of CodeWP.ai, a venture backed startup bringing AI to WordPress creators.
We're looking for new authors. Explore Isotropic Jobs.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram