WordPress: curl_setopt() error when installing plugins on 1and1 host

When trying to install/activate plugins on my WordPress site after having to reset them following a host change, I received the following error

Warning: curl_setopt(): supplied argument is not a valid cURL handle resource in ….

This turned out to be an issue with my 1and1 hosting, and how they configure their servers.

To solve the problem I added the following to my .htaccess file: