Problem: I set up a WordPress blog at 2 Amazon Web Service (AWS) EC2 instances at different availability zone. In front of them, a elastic load balancer (ELB) is set up, which redirect all HTTP port 80 requests to HTTPS port 443. Since the wp-config.php was not updated, the requests are still using HTTP instead. Therefore, I updated the below values to https:
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');
However, it falls into a redirection loop, and hit too many redirections.
Solution: Add this line in the wp-config.php
$_SERVER['HTTPS'] = 'on';
And it would fix the issue. This kind of configuration is hard to troubleshoot and you may be stuck with many hours to find this simple solution. Hope you can search this post if you encounter this particular issue.
Originally published at https://victorleungtw.com.