Fix Redirect Chain on WPEngine
Recently I encountered an issue working with a client hosted on WPEngine when converting their site to use SSL that I thought I’d share a fix for.
When converting a site to HTTPS, for SEO reasons, it’s important to 301 redirect from the non-secure URL. It’s important to not only do that for the non-secure URL but both versions of the non-secure URL. Your site uses either www or non-www for it’s primary domain. If HTTPS isn’t in the equation, you likely have whichever one you aren’t using redirecting through the other one. In this case, my client had both domains set up in their WPEngine portal under their Domains (as they should). They also had configured their www domain to forward to their non-www domain in this section, as they should.
When rolling out HTTPS and turning on “Secure All URLs” through WPEngine, it was causing a double 301 hop on the non-secure www domain. Meaning www was 301 redirecting to non-www which was 301 redirecting to https non-www. You don’t want this to be the case. The www URL should 301 redirect to https non-www.
In talking with WP Engine support, they didn’t seem to suggest it was possible to eliminate this double hop. One support rep said I should request a SSL for the www domain and force HTTPS there which would eliminate it (no). I did a bit of research and stumbled upon the solution in a Moz forum post. Essentially, the steps are:
Step 1: Under Domains in your WP Engine portal, remove the configured redirect on whichever URL you aren’t using (non-www or www) — change the setting to “No redirect”
Step 2: Under Redirection Rules in your WP Engine portal, set up a new redirection rule with the following:
Name: (this can be anything)
Domain: (whichever domain you’re wanting to redirect)
Note: Destination may be www.yourotherdomain.com depending on if www or non-www is your primary domain.
Save that and then if you use a tool like this one to check your domain mapping. There should be one version of your domain with no redirects and all the others should only have one.