htaccess file

Hello,

I am new to Drupal and I am not familiar with htaccess files. I am using D8 and I have the following problem. I bought an SSL certificate for my domain and when I access the site typing http://example.com the url is being redirected to https://example.com , but the url www.example.com unfortunately is not. So I read online that I need to redirect the www traffic to nonwww. I found this post but it is an old one and not quite what I am looking for https://www.drupal.org/node/499104
However, I understood that I need to edit the .htaccess file
So I went to my htaccess file and saw this:

# To redirect all users to access the site WITHOUT the ‘www.’ prefix,
# (http://www.example.com/foo will be redirected to http://example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]

I removed the hashtags in the last two sentences but it made no difference.
I guess it didn’t work because maybe I need to add the name of my domain but I don’t know exactly where without breaking this code.
Can somebody help please?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/22/feed