I am trying to configure SSL redirection in Apache using RewriteEngine, which will do the following:
My reasoning is that I am developing a project that uses a free SSL certificate before launch. This certificate covers the base domain, but not one of the wildcard subdomains, and it hurts to bypass the warning every time I visit one of the subdomains.
Edit: I find that I'm close, but I still can't get HTTPS to redirect HTTP to work.
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} =mydomain.com [or]
RewriteCond %{HTTP_HOST} =www.mydomain.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(.+)\.mydomain\.com$ [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]