Help with: RewriteRule ^/(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

I have my HAProxy working to route my domain.com to the correct server, but I want to rewrite the header so it will point to the www version of the domain and its not working. Does the RewriteRule work in a ssl VirtualHost:

<IfModule mod_ssl.c>
	<VirtualHost *:443>
		ServerAdmin webmaster@localhost

		DocumentRoot /var/www/kohanyim/html
		ServerName kohanyim.com:443
		#ServerAlias *.kohanyim.com:443

		# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
		# error, crit, alert, emerg.
		# It is also possible to configure the loglevel for particular
		# modules, e.g.
		#LogLevel info ssl:warn

		ErrorLog ${APACHE_LOG_DIR}/error-kohanyim-ssl.log
		CustomLog ${APACHE_LOG_DIR}/access-kohanyim-ssl.log combined

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^/(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

	</VirtualHost>
</IfModule>

or what is the best (solution or rule) to use or should both use the same DocumentRoot (if you can)?

I tried this How to redirect URL with HAProxy with the Expression: Custom acl with no success:


redirect prefix http://www.kohanyim.com code 301 if { hdr(host) -i kohanyim.com }

I believe I have found the solution after further over looking the Actions section using,
Action > Table > Action customaction: redirect prefix http://www.kohanyim.com

but not sure if this is a fix all? I’m going to need the request uri portion to make this complete. How would I make this,

RewriteRule ^/(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

work?

I did the test to see if it would carry over the url request path and it worked:

https://kohanyim.com/?q=pfsense
to
https://www.kohanyim.com/?q=pfsense

so I’m assuming I will not need additional parameters.