Http to https ssl and non www to www esp with a Wiki

From miscellus

Apache vhost rewrite rules for http to https ssl together with non www to www

I have always had problems finding vhost rewrite rules to direct non http, non-secure together with non-www redirecting to www. The main problem I had was that with Wikis especially, I would suffer problems with rewrite loops.

I followed all of the suggestions on MediaWiki help pages together with numerous ideas on StackOverflow, et al. Nothing worked in every situation, until The Final Solution, below. :-)

This works perfectly for me. I do have separate vhost.conf files for non-secure (*:80) and secure (*:443)

non secure vhost.conf

<VirtualHost *:80>
    RewriteEngine on
    ServerName    www.conversion-converter-calculator.com
    ServerAlias      conversion-converter-calculator.com
    RedirectMatch permanent ^/(.*) https://www.conversion-converter-calculator.com/$1
</VirtualHost>

secure vhost-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName    www.conversion-converter-calculator.com
    ServerAlias      www.conversion-converter-calculator.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^conversion-converter-calculator.com$
RewriteRule ^(.*)$ http://www.conversion-converter-calculator.com/$1 [R=301]
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.html [R=301,L]

... remainder of config file...