That's exactly what your problem is. When you have a $live_site your site can only be accessed on this exact URL including the schema (HTTP vs HTTPS) and exact domain. On the latter note, do remember that example.com and www.example.com are two different domains. The www denotes a subdomain.
Why's this a problem?
Let's say you have a $live_site='https://www.example.com'; and you set up www to non-www redirection. The user visits example.com. Joomla, because of the $live_site, redirects them to www.example.com. Your .htaccess file then redirects them back to example.com because of the www to non-www redirection. Then Joomla redirects them back to www.example.com, and so on and so forth. After 20 redirections the browser gives up and returns an error message that the site is inaccessible due to too many redirections.
We know about that, and we protect you from this mistake by not allowing you to set up the domain redirection features if $live_site is not empty.
You should remove all content from the $live_site and leave it empty.
As a matter of fact, $live_site must always be left empty unless you have a broken host which ends up either not populating the HTTP Host header, or populates it with an incorrect value. Even in those cases, using $live_site is meant as a temporary workaround while you hound your host to fix their broken configuration. Unfortunately, while this was (badly) documented in Mambo back in 2005 and there were some discussions in the old and now defunct JoomlaCode site a few years later, it's never been properly documented for Joomla in the past 21 years. You couldn't have known.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!