Page performance and SEO reports can report variations of TOO MANY LANDING PAGE REDIRECTS. You’re most likely see this if your domain includes www at the front. So why do they care if your site doesn’t redirect in one hop?

What they’re talking about is when a request comes to your domain without specifically including http:// or www. in the URL, the web server 301 redirects from http://domain.com to https://domain.com first, then another 301 redirect from https://domain.com to https://www.domain.com.

Page performance and SEO tests tend to hate this as it adds an unnecessary step to the page load and gives bots like Googlebot extra work. I use a super handy, free Chrome extension called Redirect Path to check the path a redirect takes in real time in my browser.

So, best practice is to just redirect straight from http://domain.com to https://www.domain.com. There are a lot of fixes out there – usually involving modifying nginx configuration or adding lines to .htaccess, like:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301] 

…OR…

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301] 

Most of these won’t work on WP Engine due to their own specific configurations for handling redirects and SSL. However, the fix is actually super easy, though it evades many as it’s quite counterintuitive.

Stop all redirects in WP Engine

The first place to stop off is your DOMAINS page. Here’s you’ll need to make sure there are no domain redirects. Here’s what mine looks like:

Next, go to your SSL page. You’ll want to ensure the setting for your domain is Secure specific URLs and not Secure all URLs:

Let WordPress Core handle it

Now all you need to do is ensure your WordPress Address (URL) and Site Address (URL) (Home and Siteurl) are set to https://www.domain.com:

This way, nothing is redirecting your site except for WordPress itself. It will redirect from http://domain.com -> https://www.domain.com in one single hop.

Stop WordPress Core redirects (to let a plugin handle it)

If you want to stop WordPress from handling the www to non-www (or vice-versa) completely, pop this into your wp-config.php:

$hostname = $_SERVER['SERVER_NAME'];
define('WP_SITEURL', 'http://' . $hostname);
define('WP_HOME', 'http://' . $hostname);

I you want to stop WordPress from handling both the protocol part (http:// and https://) as well, you can use this instead (also in wp-config.php:

$hostname = $_SERVER['SERVER_NAME'];
define('WP_SITEURL', $sScheme . $hostname);
define('WP_HOME', $sScheme . $hostname);

For reference,

$sScheme = the protocol part of the request (http:// or https://)

$hostname = the domain part of the request (including subdomains like www.domain.com)

Let Cloudflare handle redirects to https://

Do bare in mind if you’re behind Cloudflare (which I strongly recommend), you’ll need to ensure that the Always Use HTTPS is switched off. You will find this about halfway down on the Crypto page.

This effectively does the same thing as the Secure all URLs option in the WP Engine User Portal (which is also now disabled)

Here’s the full settings on my Crypto page for good measure:

HOW TO: Redirect HTTP non-www to HTTPS://www on WP Engine in 1 hop

BONUS: If you want to go a step extra and get http://domain.com to load as https://domain.com (or https://www.domain.com) without any hop at all (zero 301 redirects) you’ll want to setup HSTS preloading. Read our guide on that here.

If you’re still seeing an extra hop on the landing page, you may want to check if you have any plugins that have a force HTTPS option (like Really Simple SSL).

While I don’t believe this is a major issue for SEO anymore, it is nice to be rid of annoying warnings from any performance/SEO tests you might be running. It’s always a good idea to make things as easy as possible for bots to crawl your site too.

Elementor Page Builder

Related Articles

Copyright © 2019 Nodeflame

HOW TO: Redirect in one hop on WP Engine (http:// to https://www)

by nodeflame time to read: 3 min