I have the same problem.
I have a domain added a domain domain.com to aapanel
After that to solve the problem I added another domain www.domain.com and redirected this domain to
https://domain.com
The redirection worked but we still have a third domain:
https://www.domain.com
This combination will not be redirected. It will be redirected to the index of the first website created on aapanel. Adding this code to .htaccess doesn’t solve the problem.
RewriteEngine On
RewriteCond %{SERVER_PORT} !443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} www.domain.com$ [NC]
RewriteRule .*$ https://domain.com/$1 [R=301,L]