URL redirect rewrite using the htaccess file

how to redirect https://domain.com to https://www.domain.com?

This works with OpenLiteSpeed

RewriteCond %{HTTP_HOST} ^example.com[NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]