There is something terribly wrong here.
I always create my sites with ee site create domain.com --le --wpredis --php7
.
If I want it with www I just do:
cd /var/www/domain.com/htdocs/
wp option set home https://www.domain.com
wp option set site_url https://www.domain.com
Just because I'm a bit paranoid I also like to:
wp search-replace https://domain.com https://www.domain.com
It's done, WP will take care itself of redirecting to the right URL as configured above.