Here I log the htaccess redirect code I use for the sites that I manage. Put the code in the top of the htaccess file. For some of the below codes the sub folder URL redirects did not work correct when the code was after the Joomla default htaccess entries.
To redirect all pages from www to non-www domains.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
To redirect all pages from non-www to www domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
To redirect all http to https.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
To redirect a domain to a different domain. Both the www and non-www variant of the domain are redirected.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?testing1.com$
RewriteRule ^(.*)$ https://testing2.com/$1 [L,R]
To redirect a single file to a new URL.
Redirect "/location/of/file.mp4" https://www.testing.com/the/new/location.mp4
Hope this helps