11 Aug AWS, EC2, ELB, and WordPress Canonical URLs
Oof, that’s a lot of acronyms. Here’s the scenario – you’re staging a new site, and you’re hosting the WordPress site on Amazon Web Services on an EC2 instance. So far so good. You add an elastic load balancer to the mix with a domain of something like ABC-test-123.elb.amazon.com. You set your WordPress home and site URLs to match – ABC-test-123.elb.amazon.com.
And poof. You get a “too many redirects” error just on your home page. You spend about a million hours trying all the usual fixes with your .htaccess file and server settings to no avail.
Here’s what’s happening. The WordPress canonical URL function changes your url to all lowercase letters – abc-test-123.elb.amazon.com . Then the ELB changes it back to all uppercase because that’s what it’s set to use. And then you get too many redirects. The solution is to set all URLs to be all lowercase. This is really best practice anyway, but it’s good to remember when you’re using case sensitive elements outside of WordPress.
My team spent hours troubleshooting this so that you don’t have to. The more you know!