Herewith an example config from a working production Apache environment (/etc/httpd/ configuration folder) for PERMANENT (301) URL redirection.
Please note the first will redirect all traffic from http:// to https:// so remove if not needed.
RewriteEngine On
# Force HTTP -> HTTPS redirection on entire domain
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
## Redirect www to non-www permanently - both http and https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1$1 [R=301,L]