Hello, and welcome to another episode of Continuous Improvement. I’m your host, Victor. Today, we’re going to discuss a common issue that many WordPress users face when setting up their websites on AWS EC2 instances. Specifically, we’ll dive into the problem of endless redirection loops and how to fix them. So, let’s get started!

Imagine this. You set up your WordPress blog on two AWS EC2 instances located in different availability zones. To manage the traffic, you wisely configure an Elastic Load Balancer (ELB) to redirect all HTTP requests to HTTPS. However, you encounter a roadblock when your requests keep looping endlessly, resulting in an error stating “too many redirections.” Frustrating, right?

Luckily, there’s a simple solution to this problem. Let me walk you through it step by step. Here’s what you need to do.

First, open up your wp-config.php file. This file holds important configurations for your WordPress website. Look for the following lines of code:

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');

You’ll notice that these lines specify the WP_SITEURL and WP_HOME values using HTTPS. While this seems like the correct approach, it actually creates the endless redirection loop that we’re trying to solve.

So, here’s the fix. Add the following line to your wp-config.php file:

$_SERVER['HTTPS'] = 'on';

By adding this line, you’re explicitly telling WordPress that HTTPS is enabled. This bypasses the endless redirection loop issue and ensures a smooth user experience.

And there you have it! A simple solution to a potentially frustrating problem. Configurations like these can be challenging to troubleshoot, and you might spend hours searching for a solution. But with this fix, you’ll save valuable time and get your website up and running smoothly.

I hope you found this episode helpful. If you have any other WordPress-related issues or questions, feel free to reach out to me on our podcast’s website or social media channels. Remember, continuous improvement is all about learning, growing, and overcoming challenges one step at a time.

Thank you for listening to Continuous Improvement. I’m your host, Victor, signing off. Stay curious, keep improving, and until next time!