htaccess force https not working if there is an URI


I’ve never worked with Apache, so I’m a completely newbie.

I have a multihosting account on a provider website, where 3 domain are used. I want to force https connection on a domain, let’s say example.com, which is not the main domain of the hosting plan. What I did is to add an .htaccess file in the path examplecom/public_html, the folder where there are all the file of the website. In the .htaccess I have copy-pasted this strings from the provider guide:

RewriteEngine on RewriteBase / RewriteCond %{HTTPS} !on RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301] 

The website works correctly if I go to a page with an non-empty URI, but it doesn’t on the main page. In example: http://example.com/anypage is correctly redirected to https://www.example.com/anypage, while http://example.com/ is redirected to https://www.example.com/public_html, and can’t understand why.