Beware Of Redirect Pain When Migrating To WP Engine

Jan 30, 2014Ryan Burnette

If you're starting a fresh WordPress site on WP Engine, this probably won't effect you, but if you're like me and you have – or are in the process – of migrating a site to WP Engine, you'll want to consider redirection before making the switch.

Perhaps when I started the process of migrating my client's site into WP Engine I could have more carefully read their redirect documentation. I do, however, think that WP Engine could have done more to make me aware of what I should watch out for before I began.

Within hours of the move something was clearly wrong. This site had been migrated from another CMS to WordPress back in 2012. There were literally thousands of URLs for pages and assets that relied on redirects in the site's .htaccess file. I had checked with support to make sure the .htaccess file's redirects would be respected. I was told that the answer was yes because, although it's in a reverse proxy behind Nginx on WP Engine, their platform does indeed utilize Apache. It wasn't completely true that you can handle redirects on WP Engine through the .htaccess file. This is when it got complicated.

WP Engine uses both Nginx and Apache in a reverse proxy configuration. That means HTTP requests hit the Nginx server and in some cases those requests are relayed to Apache. In other cases they're handled without a call to Apache. That means that only on requests which involve a call to Apache will the .htaccess redirects be respected.

In my case I ended up using Integrity to run crawls looking for broken links and assets over and over. Each time I'd identify a group of broken links that I could fix by adding something to my .htaccess file. In the end I was left with a long list of 404s that couldn't be handled using the .htaccess file. After that I used the redirect interface WP Engine provides to write simple regex rules to recreate my needed redirects.There were some caveats so I advise everyone to carefully review WP Engine's regex documentation before creating any rules.

If I could do it all again I would not rely upon the .htaccess file at all. It required doing testing and reverse engineering to figure out which cases called back to Apache and which didn't. Only when Apache gets called will an .htaccess redirect work. There were further limitations on match rules that I didn't expect.

Take the time to migrate all your redirects into the WP Engine interface. Unfortunately you can't upload a text file. You have to build them there. This is tedious if you have many redirect rules. I thought about writing them in the format of an Nginx configuration file and submitting them in a ticket, but another convoluted conversation with support didn't appeal to me.

I'm still a fan of WP Engine on the merits of their platform. It hardens and improves WordPress in ways that no other host can offer.

Good luck!

Blog Index