I think there is some confusion here. A domain name is for example www.mydomain.com but mydomain.com is another domain name such as w.mydomain.com or ww.mydomain.com .
You must have for your website only one main domain (www.mydomain.com) and all other must redirect to the main domain such as mydomain.com must redirect to www.mydomain.com. If not you have duplicated content.
Many thanks for suggestion. I decided to use domain.com as default and I have altered my .htaccess to redirect www.domain.com to domain.com, tested the redirect and it is working. Below is the changes I made to .htaccess: