Problem

I set up a WordPress blog on two Amazon Web Services (AWS) EC2 instances located in different availability zones. In front of these instances, an Elastic Load Balancer (ELB) is configured to redirect all HTTP requests on port 80 to HTTPS on port 443. Since the wp-config.php file was not updated to reflect this change, the requests were still using HTTP. To correct this, I updated the following values to use HTTPS:

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

However, this led to an endless redirection loop, eventually resulting in an error stating “too many redirections.”

Solution

To resolve the issue, add the following line to the wp-config.php file:

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

This will fix the issue. Configurations like this can be challenging to troubleshoot, and you may spend many hours looking for a simple solution. Hopefully, this post will save you some time if you encounter this particular issue.