How to make / create redirect from one domain to other with www using htaccess on apache?

For make / create redirect from one domain to other with www using htaccess on apache?

Just do like this:

RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteRule ^(.*)$ https://yourotherdomain.com/$1 [R=301,NC,L]

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

and insert in into your .htaccess file in the root of your website