We had the same problem with a nocpommerce 4.30 site hosted on linux. Http requests are being redirected to https with www, as are https without www redirected to https with www.
What fixed it was using https://www.example.com/ (example.com = site_domain) as the store url (Configuration -> Stores -> Store URL -> https://www.example.com/)
What fixed it was using https://www.example.com/ (example.com = site_domain) as the store url (Configuration -> Stores -> Store URL -> https://www.example.com/)
In our case (specific store that had the same problem) we are redirecting (nginx config) http requests to https with www and https requests without www to https with www.
Sorry for the misunderstanding.